iT邦幫忙

2021 iThome 鐵人賽

DAY 17
0
Modern Web

YDKJS 一邊讀 You Don't Know JS Yet 一邊卡關一邊弄懂的日子 ԅ(≖‿≖ԅ)系列 第 17

Day17 - this&Object Prototypes Ch3 Objects - Iteration 開頭

var myArr = ['燃麵', '生菜', '花椒'];
myArr.a = '雉雞';

// 由 indices
// 間接取得 value
for (var i = 0; i < myArr.length; i++) {
         console.log( myArr[i] ); // '燃麵', '生菜', '花椒'
}

// 由一個的 enumerable 的 property
// 間接取得 value
for (var i in myArr) {
    console.log( myArr[i] ); // '燃麵', '生菜', '花椒', '雉雞'
}

// 直接取得 value
for (var item of myArr) {
    console.log( item ); // '燃麵', '生菜', '花椒'
}

今天先理解到這邊~如果上述內容有出入,希望路過的朋友能俠義挺身糾正,感恩的心 ԅ(≖‿≖ԅ)


上一篇
Day16 - this&Object Prototypes Ch3 Objects - Iteration 開頭
下一篇
Day18 - this&Object Prototypes Ch3 Objects - Iteration 開頭
系列文
YDKJS 一邊讀 You Don't Know JS Yet 一邊卡關一邊弄懂的日子 ԅ(≖‿≖ԅ)30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言