遍歷對象屬性 - Iterate through object properties

問題:

var obj = { name: "Simon", age: "20", clothing: { style: "simple", hipster: false } } for(var propt in obj){ console.log(propt + ': ' + obj[propt]); }

How does the variable propt represent the properties of the object? 變量propt如何表示對象的屬性? It's not a built-in method or property. 它不是內置方法或屬性。 Why does it come up with every property in the object? 爲何它包含對象中的每一個屬性? ide


解決方案:

參考一: https://stackoom.com/question/YsRv/遍歷對象屬性
參考二: https://oldbug.net/q/YsRv/Iterate-through-object-properties
相關文章
相關標籤/搜索