使用 in 搭配 for 时, array 内所有 enumerable 为 true 的 property 都会被抓出来,所以作者建议 in 搭配 for 的用法用在 object 就好
var myArr = ['a','b','c'];
// property 的预设 enumerable 是 true
myArr['food'] = '燃面'
console.log(myArr) // ["a", "b", "c"]
console.log(1 in myArr); // true
console.log(myArr.hasOwnProperty( 1 )); // true
// 作者建议 for 回圈用在 array 身上,还是以这种传统方式
for (var i=0; i<myArr.length;i++) {
console.log( myArr[i] );
} // 'a','b','c'
// 因为使用 in 搭配 for 时, array 内所有 enumerable 为 true 的 property 都会被抓出来
for (item in myArr) {
console.log( item );
} // "0","1","2","food"
今天笔记到这,如果内容有出入,都在麻烦纠正了,谢谢您 ԅ(≖‿≖ԅ)
<<: 13 - Logs - 挖掘系统内部发生的状况 (1/4) - Logs 与 Filebeat 的基本介绍
前言 也许你会觉得,这个标题下得很神经。没错!因为今天要正式进入新的主题-神经机器翻译。我们今天将会...
牛墟婆婆肉粽蛋饼(其实他没有店名@@) 地点:盐水区土库路(朝琴路右转一下子就到) 时间:早上 刚到...
在范例四的说明中, 我们已下载伊甸基金会释出的口罩脸孔资料集, 我们预计使用这个资料集进行训练、产生...
这是 Roblox 从零开始系列,效果章节的第三个单元,今天你将学会如何制作自己想要的粒子效果 Pa...
若你是使用 ORM ( Object Relational Mapping ) 来操作资料库的话,那...