1.js判斷一個元素是否在數組中
(1).let arr = [1,2,3];
arr.includes(1) // true
arr.includes(5) //false
(2).a=["1", "3", "2", "3", "0"];
console.log(a.indexOf ('3'));//1
console.log(a.indexOf ('4'));//-1
1.js判斷一個元素是否在數組中
(1).let arr = [1,2,3];
arr.includes(1) // true
arr.includes(5) //false
(2).a=["1", "3", "2", "3", "0"];
console.log(a.indexOf ('3'));//1
console.log(a.indexOf ('4'));//-1
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。