Objects for Structuring Data

 

 

Lonce Wyse

Communication & New Media

lonce.wyse@cnm.nus.sg

Objects  

 

                          {  "radius" : 6,  

                              "position" :  { ... }  , 

                              "changeRadius"  :   function(...){...}   

                            }  

Define

Objects  

 

var myCircle = {  "radius" : 6,  

                              "position" :  { ... }  , 

                              "changeRadius"  :   function(...){...}   

                            }  

Define

Objects  


var myCircle = {  "radius" : 6,  

                              "position" :  { ... }  , 

                              "changeRadius"  :   function(...){...}   

                            }


Use

Define

 

myCircle.radius = 6;     or  myCircle["radius"] = 6;  

(note pattern!)

Objects  

 

var myCircle = {  "radius" : 6,  

                              "position" :  { ... }  , 

                              "changeRadius"  :   function(...){...}   

                            }

 

Use

Define


var px = myCircle.position.x;    

or  myCircle.changeRadius(10)

(note pattern!)

Made with Slides.com