使用11:数组的索引of方法:字符串类型let str='orange '; str.indexof('o ); //0字符串中字符o出现的位置str.indexof('n ); //3字符串中字符n出现的位置str.indexof('c ); //-1不出现字符串的字符(不匹配的字符为-1)实际上下标为:0----------------let num=2016; num.indexof(2; 如果不对//uncaught typeerror 3360 num.indexofisnotafunctionnumber类型使用索引of方法:必须将number类型转换为字符串类型; 第一种方法: let num='2016 '; num.indexof(2; //0第二种方法:num.tostring(.indexof ) ) 2; //0第三种方法:('num ).indexOf(2) 2; //0在字符串中取出该字符出现的位置; ------------------------arr or arr.index of (orange ); //0数组第一个元素出现' orange '出现的位置arr.indexof('o ); //-1数组中出现o的位置,如果未分配则返回-1。