JavaScript - literal notation for adding methods in Object

1:  var james = {  
2:    job: "programmer",  
3:    married: false,  
4:    speak: function( msg ) {  
5:      console.log("Hello, I am feeling "+msg);  
6:    }  
7:  };  
8:  james.speak("great");  
9:  james.speak("just okay");  

No comments:

Post a Comment