Object oriented
JavaScript objects are based on associative arrays, improved with the prototyping inclusion. The properties and values can be changed at runtime. Another common way to create objects is using the JavaScript Object Notation (JSON) or using functions.
Let's see how an object created by JavaScript code looks, and its JSON representation:
// Let's create the person object
function Person(first, last, age) {
this.firstName = first;
this.lastName = last;
this.age = age;
}
var diego = new Person("Diego", "Arguelles", 27);
//JSON representation of the same object
{
firstName: "Diego",
lastName: "Arguelles",
age: 27
}
推薦閱讀
- 通信網絡基礎與設備
- Application Development with Qt Creator(Second Edition)
- Twilio Cookbook
- Building Django 2.0 Web Applications
- Hands-On Chatbot Development with Alexa Skills and Amazon Lex
- Drush User’s Guide
- 互聯網安全的40個智慧洞見:2014年中國互聯網安全大會文集
- 2018網信發展報告
- Microsoft Dynamics CRM 2011 Applications(MB2-868) Certification Guide
- 網絡設計與應用(第2版)
- 5G非正交多址接入技術:理論、算法與實現
- 移動互聯網新思維
- Hands-On Reactive Programming in Spring 5
- 趣話通信:6G的前世、今生和未來
- 中國信息化年鑒2017