JS/JavaScript

[JS] 08. Object

밍글링글링 2017. 8. 28. 13:37
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