官术网_书友最值得收藏!

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
}
主站蜘蛛池模板: 鹿邑县| 正安县| 房山区| 安徽省| 丹阳市| 新和县| 马公市| 泾阳县| 兴安盟| 平南县| 通渭县| 如东县| 井研县| 乌鲁木齐县| 清远市| 新和县| 调兵山市| 梨树县| 襄城县| 高台县| 辉南县| 小金县| 太康县| 格尔木市| 沙雅县| 东丰县| 花莲市| 宁乡县| 泰来县| 县级市| 绍兴市| 万年县| 普安县| 扎兰屯市| 鹤岗市| 科技| 新和县| 连南| 特克斯县| 两当县| 逊克县|