<script type= "Text/javascript" >/*js object: The responsibility of the object is to invoke the property and invoke the method *///1. Three ways to create an object var obj = {}; Commonly used and does not waste space var obj = new Object ();//var obj = Object.create ();/* The Third way to test the time there is a problem, under Baidu, found Object.create () method to create an object that has a specified prototype and several specified properties. Parameter: Prototype required. The object to use as a prototype. can be null. Descriptors is optional. A JavaScript object that contains one or more property descriptors. *///2. The presence of a key-value pair: jsonvar person = {username: "Xiaobai"}//object's additions and deletions person.age = "a";p erson.address = "Nanjing"; Console.log ( person.username+ "= = =" +person.age+ "= = =" +person.address);//Modified value Person.username = "Xiaoking";p erson.age = 20;// Remove value Delete person.age;//do not understand the alert or use Console//3.json object var data = {username: "Poseidon"}/* the value there are two first: object. Property facilitates invocation of properties The second type: Object ["attribute name"] Convenient value */console.log (data.username+ "= = =" +data["username"]);/* Single attribute can be used this way, but multi-attribute JSON object is not the same */var params = {" User.Name ":" "," User.age ":" "}params[" User.Name "]//value cannot use point Params.user.name, will error console[" log "] (" console is also object "); var Console = {log:function (msg) {}}//4. Write a jquery framework function $ (ID) {var obj = {css:function () {}html:function () {}}} (function () {var window.$ = document;}) (window); var $ = function (ID) {if (Id.indexof ("#")) id = id.replace ("#", "" "), var dom = document.getElementById (ID); return { Css:function (Key,value) {if (typeof key = = = "Object") {}else{if (typeof key = = = "Number") value = value + "px";d om["style"] [ Key] = value;}}}} 5. You can learn the latest DOM knowledge for (Var key in document) {Console.log (Document[key]) without buying a book of any DOM object;} </script>
A little understanding of JavaScript objects