介绍四种阵列运用:
const num = [ 1 , 2 , 3 , 7 , 8 , 9 ]
const newNum = num.find(function(item){
return item >= 5;
})
console.log(newNum);
如图所示找出大於5的值,理论会印出7、8、9这三个值,但
使用 find 只会找寻出符合条件的第一笔资料。
const colors = [ "red" , "black" , "white" , "blue" ]
const color = colors.findIndex(function(item){
return item == "black";
})
console.log(color);
如图所示使用 findIndex 找出符合条件的资料索引。
回传的值为 1 ,阵列 0 为排序第一个, 1 为排序第二个。
今天到此结束。
>>: Day22-Kubernetes 那些事 - Namespace
因应国际化的需求,专案决定也要符合 international 的规格,Navbar 右上角的「选择...
规划syslog连接器 我们可以使用适合的Linux Log Analytics Agent,从以L...
Massive Storage Management tags: IT铁人 其实这块要讲的就是有关D...
大家好,今天是最後一天,今天跟大家介绍shared_preferences,可以把一些简单的设定的东...
★2021 IPBC Taiwan|创新科技论坛-智胜5G 领航未来!★ 经济部工业局 主办! ht...