Javascript Object learning notes (1)-basic object knowledge

Source: Internet
Author: User

1: Create an object (simple)
Var point = new Object ();
Point. x = 10;
Point. y = 10;
2: direct use of objects (objects can be initialized in json format)
Var point = {x: 2.3, y:-1.2}
Var rectangle = {upperLeft: {x: point. x, y: point. y },
LowerRight: {x: 100, y: 200}
};
3: null and undefined
Var x; (variable a has been declared, but the default value is undefined if no value is assigned)
Alert (u); (call undefined u variable, leading to null exception null)

4: basic type and reference type
The first thing to know is that numeric values, strings, null, and undefined belong to the basic type. Objects and arrays are reference types.
Differences between basic and reference types

Basic Type:
Var a = 3.14;
Var B =;
A = 4;
In the alert (B) pop-up 3.14, only the value of a is assigned to B. Changing the value of B is not affected.

Reference Type:
Var a = [1, 2, 3];
Var B =;
A [0] = 99;
Alert (B [0]) pops up 99. Here, the array address of a in the memory is referenced, which is similar to the pointer address in c.


Not yet to be continued (in the learning stage, if you have any mistakes, please point them out. Thank you)

From: I can't say goodbye

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.