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

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
}
主站蜘蛛池模板: 南木林县| 洱源县| 博兴县| 济宁市| 准格尔旗| 阳山县| 兰溪市| 革吉县| 五河县| 黄陵县| 清原| 广昌县| 阳信县| 金溪县| 绍兴市| 民和| 渭源县| 康马县| 碌曲县| 辽宁省| 十堰市| 托克托县| 房产| 湘潭县| 克拉玛依市| 溆浦县| 越西县| 军事| 崇礼县| 武鸣县| 呼伦贝尔市| 临桂县| 南岸区| 五峰| 阿拉尔市| 柏乡县| 奎屯市| 萨嘎县| 贵州省| 上林县| 东海县|