togakangaroo

Learn Js Nola - Objects

Apr 18th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Objects are just grouping of variables
  2. var person = {
  3.     'firstName': "George",
  4.     'lastName': "Mauer",
  5.     'age': 29
  6. };
  7. // Notice the last pair doesn't get a comma.
  8.  
  9. // You can also add properties to an object like this
  10. person.birthplace = "Kiev";
  11. // or
  12. person['worksIn'] = "Launchpad";
  13. // Objecs can be nested
  14. person.birthday = {
  15.     'month': "June",
  16.     'year': 1982
  17. };
  18.  
  19. // You can fetch them like this
  20. person.firstName;
  21. // or
  22. person['firstName'];
  23. // It's all the same
  24. person.birthday.month;
Add Comment
Please, Sign In to add comment