js数组includes与indexOf区别
作者:互联网
includes
let arr=[1,true,3];
a.includes(1) //=>true;
a.includes(11) //=>false;
indexOfqu
let a=[1,2,3,NaN];
a.includes(1) //=>0
a.indexOf(11) //=>-1
区别
includes认为NaN与自身相等。
let a=[1,2,3,NaN];
a.includes(NaN) //=>true
a.indexOf(NaN) //=>-1
标签:11,indexOf,NaN,js,let,includes,true 来源: https://blog.csdn.net/weixin_50821119/article/details/122463000