Is there any function in jQuery that is equivalent to PHP's array_column()?

前端 未结 6 1332
轻奢々
轻奢々 2021-02-10 04:57

What is the equivalent to PHP\'s array_column() in jQuery? I need the data inside the array without looping, in the same way as in PHP.

6条回答
  •  被撕碎了的回忆
    2021-02-10 05:55

    I use this to build an object ~ php like associative array. by selecting the .id of the source array, and build that id as the index of the new array and contains the same content of the old source array.

    var categoriesById={};
    
    for(item in cacheObject.Categories){
    categoriesById[cacheObject.Categories[item].id]=cacheObject.Categories[item];
    }
    

提交回复
热议问题