JS/JavaScript

[JS] 08. Object

밍글링글링 2017. 8. 28.
728x90

08_Object.html

<script>
//Creation an object literal.
var myObject ={
        sayHello: function(){
            console.log("hello");
        },
        myName: "Rebecca"
};
myObject.sayHello(); //"hello"
console.log(myObject.myName); //"Rebecca"

//the key portion of each key-value pair can be written as any valid JavaScript identifier.
//a string (wrapped in quotes), or a number:
    var myObject = {
        validIdentifier: 123,
        "some string": 456
        99999: 789
};
</script>
 

728x90

'JS > JavaScript' 카테고리의 다른 글

[JS] 10. TypeOf  (0) 2017.08.28
[JS] 09. Function  (0) 2017.08.28
[JS] 07. Array  (0) 2017.08.28
[JS] 06. Loop  (0) 2017.08.28
[JS] 05. Conditional_Code  (0) 2017.08.28

댓글