Javascript Objects

A JavaScript object is a collection of properties, and a property is an association between a name and a value. A property’s value can be a function, in which case the property is known as a method.

Except number, string, boolean and undefined, everything in Javascript is object.

When an object is set to a variable, the variable is called reference type variable since it includes the reference (address) value of the object.

1. Object creation

1) Using object literal

2) using object creator (new Object())

3) using object constructor

2. Object property access/update

1) using [] or .

2) using for statement

3. Object/object property delete

The delete operator removes a property from an object.

The delete operator has no effect on regular variables, only properties of an object.

Since Javascript is garbage collected, you don’t need to delete objects themselves – they will be removed when there is no way to refer to them anymore.

4. Object references

1) Two variables share one object

Object Reference

2) Object comparison

Object Comparison

3) Always “Call by value”

Call by Value

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d 블로거가 이것을 좋아합니다: