标签:返回 bsp 下标 color UNC rip abc from 遍历
1. Array.from(v) : 将伪数组对象或可遍历对象转换为真数组
<body> <div>div1</div> <div>div2</div> <div>div3</div> <br> <script> let divs = document.getElementsByTagName(‘div‘); var arrDiv=‘‘ Array.from(divs).forEach(function (item, index) { console.log(item, index); }) </script> </body>
2. Array.of(v1, v2, v3) : 将一系列值转换成数组
3. find(function(value, index, arr){return true}) : 找出第一个满足条件返回true的元素
let arr1 = [1,3,5,2,6,7,3]; let result = arr1.find(function (item, index) { return item >3 }); console.log(result);//5
4 findIndex(function(value, index, arr){return true}) : 找出第一个满足条件返回true的元素下标
let arr1 = [1,3,5,2,6,7,3]; let result1 = arr1.findIndex(function (item, index) { return item >3 }); console.log(result1);//2
5 findIndex(function(value, index, arr){return true}) : 找出第一个满足条件返回true的元素下标
let arr1 = [1,3,5,2,6,7,3]; let result1 = arr1.findIndex(function (item, index) { return item >3 }); console.log(result1);//2
标签:返回 bsp 下标 color UNC rip abc from 遍历
原文地址:https://www.cnblogs.com/hack-ing/p/12012701.html