对象数组的遍历相关知识underscore

for(name in object){}; 遍历对象{};

for(var i=0;i<name.length;i++){};遍历数组;

以数组的的形式打印: JSON.stringify(sht);  console.log()

判断对象中是否含有sths.hasOwnProrert(sth);//如果含有元素则返回值为true,如果不含有元素则返回值为false;
_.first([5,2,3,8,6]); =>5 //输出数组的第一个元素
_.initial([5,2,3,8,6]);=>[5,2,3,8] //输出结果为除了最后一个元素的其他元素。
_.last([5,2,3,8,6]);  =>6   //返回值为最后一个元素
_.without([5,2,3,8,6],5,2);  =>[3,8,6]  //删除数组后的值;
_.intersection([5,2,3,8,6],[6,2,5],[6,2]); =>[6,2]  //取数组的交集

_.result(Object,'a[0].b.c1')    //获取对象中的深层元素
_.some(users,['active',false])  //判断对象中的是否含有某些元素,存在:true,无:false
_.valae





猜你喜欢

转载自1508144386.iteye.com/blog/2412697