2015년 9월 5일 토요일

Javascript object

Let's see Javascript Object. We'll see Javascript specific things and something is good to know. Learning test is written using Jasmine. Please refer Jasmine usage which I wrote before if you have interest it. 

1. Object and property
Javascript designed based on object which have simple form. The object is a collection of attributes. Those attribute have its own name and value. They are used to express many behavior and characteristics of object. Javascript variable can save not only value but also function itself, so that javascript can express behavior of object using method like ordinary object oriented language. The attribute can be expressed like below,  

objectName.propertyName

propertyName should be string or something can be converted to string.


2. Iterate attribute

You can iterates attributes of object using fon-in statement, Object.keys(o), Object.getOwnPropertyNames(o).

3. Create object

You can create object using initializer, construct function  or Object.create.

4. Prototype attributes
Every javascript object inherite "prototype" object. So, If you add attribute like [line 14], all instances of Male will have this attribute.

5. Define getter, setter

6. Delete attribute
7. Compare object
8. Reference
- MDN - https://developer.mozilla.org/en/docs/Web/JavaScript
- Jasmine - http://jasmine.github.io/2.3/introduction.html

댓글 없음:

댓글 쓰기