OReilly JavaScript The Good Parts 关于变量Property的访问
2012-12-11 08:49
633 查看
var flight = { airline: "spring", number: 123, departure:{ time:"09-22 14:55", city:"shanghai" } }; document.writeln(typeof flight); document.writeln(typeof flight.airline); document.writeln(typeof flight.number); document.writeln(typeof flight.toString); document.writeln(flight.hasOwnProperty('number')); document.writeln(flight.hasOwnProperty('arrival')); /*result object string number function true false */
for (name in flight) { if (typeof flight.name != 'function') { document.write(name + ':' + flight[name]); } // document.write(typeof name); } /*There is no guarantee on the order of the names, If you want to assure that the properties appear in a particular order, */ var properties = [ 'airline', 'number' ]; for (i = 0 ; i < properties.length; i++) { document.writeln(properties[i] + ':' + flight[properties[i]]); }
相关文章推荐
- OReilly JavaScript The Good Parts 关于变量的使用
- OReilly JavaScript The Good Parts 关于Object.prototype和delete
- functional继承模式 来自javascript:the good parts
- Bad Parts(Appendix B. of JavaScript: The Good Parts)
- JavaScript.The.Good.Parts阅读笔记(一)假值与===运算符
- JavaScript 编程珠玑 - 《JavaScript: The good parts》总结(1)
- Grammar(Chapter 2 of JavaScript: The Good Parts)
- Functions part1(Chapter 4 of JavaScript: The Good Parts)
- JavaScript.The.Good.Parts阅读笔记(一)假值与===运算符
- javascript the good parts Chapter 4 Functions
- Functions part2(Chapter 4 of JavaScript: The Good Parts)
- JavaScript- The Good Parts function Curry
- Awful Parts(Appendix A. of JavaScript: The Good Parts)
- 读书笔记 JavaScript:The Good Parts
- JavaScript: The Good Parts
- JavaScript:The Good Parts学习笔记1
- Arrays(Chapter 6 of JavaScript: The Good Parts)
- JavaScript 编程珠玑 - 《JavaScript: The good parts》总结(2)
- 读 《JavaScript: The Good Parts》 有感
- Methods(Chapter 8 of JavaScript: The Good Parts)