[ES6] Array.find()

Convenient method to find one item in an array, avoid writing and  for + if:

let arys = [1,,5,,6] ;
let target = 6;
let res = arys.find(item => item === target);
console.log(res);

 

posted @ 2015-11-12 03:23  Zhentiw  阅读(544)  评论(0编辑  收藏  举报