JS Object Type

Source: Internet
Author: User

Overview

All things in JavaScript are objects. JavaScript is an object-oriented language, but JavaScript does not use classes. In JavaScript, classes are not created and objects are not created through classes (as in other object-oriented languages). JavaScript is based on prototype, not class-based.

/** * Object Copy * http://www.cnblogs.com/yichengbo/archive/2014/07/10/3835882.html */function Testobjectclone () {debugger;        var clone = function (source) {var result = {};        for (var key in source) {Result[key] = typeof Source[key] = = = ' object '? Deepcoyp (Source[key]): Source[key];    } return result;    } var obj0 = {aaa: "AAA", BBB: "BBB"} var obj1 = Clone (obj0); OBJ1.AAA = "CCC";} /** * Map Type Implementation * http://www.cnblogs.com/superjt/archive/2012/12/21/2827742.html */function Testvirtualmapobject () {de    Bugger;    var mArr = {};    marr["A01"] = "AAA";    marr["A02"] = "BBB";    marr["A03"] = "CCC";    marr["A03"] = "DDD";    marr["A03"] = null;    Delete marr["A03"];    Delete marr["A03"]; Marr.pop ("A03");}    /** * Array type Object Test * http://www.w3school.com.cn/jsref/jsref_obj_array.asp */function testarrayobject () {debugger;    var mArr = [];    var str0 = "AAA";    var str1 = "BBB";    Marr[0] = STR0; MARR[1] = str1;   Marr.push (STR1); Marr.pop ();}    /** * Basic Object Type Test * http://www.w3school.com.cn/js/js_objects.asp */function testobject () {debugger;    How to create an object var obj0 = {};    var obj1 = new Object ();    Access Object Properties Obj0.property = "AAA";    Obj0.name = "BBB";    Console.log (Obj0.property);    Console.log (obj0["property"]);     Delete Object properties Delete obj0.name;     Use Object Builder var person = new Person ("Wang", "999");    Traverse Object properties for (prop in person) {Console.log (prop); } console.log (Closeobj.getname ());}    constructor functions function person (name, age) {this.name = name; This.age = age;} PrototypePerson.prototype.birthday; Person.prototype.address = "CCC";    Closure var closeobj = {name: "AAA", Getname:function () {return this.name; }};

  

Reference:

JavaScript objects

JS Object (Classic) Comprehensive

About adding, deleting, and modifying properties of objects to JavaScript objects

JS Object Type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.