0331


waitUntill:
  1. 'load', //等待 “load” 事件触发
  2. 'domcontentloaded', //等待 “domcontentloaded” 事件触发
  3. 'networkidle0', //在 500ms 内没有任何网络连接
  4. 'networkidle2' //在 500ms 内网络连接个数不超过 2 个

索引辨析:

indexOf() 

在字符串中寻找索引

1 const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?';
2 const searchTerm = 'dog';
3 const indexOfFirst = paragraph.indexOf(searchTerm);
console.log('The index of the first "' + searchTerm + '" from the beginning is ' + indexOfFirst);
// expected output: "The index of the first "dog" from the beginning is 40"

findIndex()

var ages = [3, 10, 18, 20];
 
function checkAdult(age) {
    return age >= 18;
}
 
function myFunction() {
    document.getElementById("demo").innerHTML = ages.findIndex(checkAdult);  //2
}

寻找的的是数组中元素的索引

猜你喜欢

转载自www.cnblogs.com/George19950505/p/12603417.html