Js 一些纪要

Js通过值获取索引下标

    var list = [1, 2, 3, 4, 5, 6, 7, 8]
    var index = list.map(item => item).indexOf(8)
    console.log(index) //7

  

    var array = [{
        name: "aa"
    }, {
        name: "bb"
    }, {
        name: "cc"
    }, {
        name: "dd"
    }, {
        name: "ee"
    }]
    var line= array.map(item => item.name).indexOf('dd')
    console.log(line) //3

  

posted on 2020-06-29 10:48  肥冬瓜  阅读(115)  评论(0编辑  收藏  举报

导航