javascript常用操作

数组:

filter:筛选出符合条件的数组元素

    [1,2,3,4,5,8,19,22,34].filter( function aa(age){ return age>3 } )
    >>(6) [4, 5, 8, 19, 22, 34]

indexOf:获取数组元素的坐标

    ['a','b','c'].indexOf('b')
    >>1

    ['a','b','c'].indexOf('e')
    >>-1   //-1表示没有

join:数组转字符串

    [12,12,33,3].join()
    >>"12,12,33,3"

    [12,12,33,3].join('——')
    >>"12——12——33——3"

  

猜你喜欢

转载自www.cnblogs.com/thing/p/10283844.html