less than 1 minute read

Property

  • write val_name/key on left side.
  • write value on right side.
  • can insert object into object
var book ={
    title: "code,code,code",
    page: 123
    writer :{
        name : "?",
        from : "?",
        birth : 1234
        promotion : function(){}
    }
};

property add, modify,extraction

  • add key, modify value on key and extract value on key in object
var obj = {};
obj.abc = 123; /* add abc var that have val 123 in to obj Object */
obj.abc = 456; /* change value 123 to 456 in var abc */
obj["def"] = "big"; /* add abc var that have val 123 in to obj Object */
obj["def"] = "small"; /* change value 123 to 456 in var abc */
console.log(obj.def);

for~in

  • 오브젝트에서 프로퍼티를 열거
var sports ={
    soccer : "socc",
    baseball : "baseb"
}

for (var item in sports){
    console.log(item);
    console.log(sports[item]);
}