Guest User

Untitled

a guest
May 26th, 2018
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const person = {
  2. firstName: 'Steve',
  3. lastName: 'Smith',
  4. age: 30,
  5. email: 'steve@aol.com',
  6. hobbies: ['music', 'sports'],
  7. address: {
  8. city: 'Miami',
  9. state: 'FL'
  10. },
  11. getBirthYear: function(){
  12. return 2018 - this.age;
  13. }
  14.  
  15. }
  16.  
  17. let val;
  18.  
  19. val = person;
  20.  
  21. //Get specifice value
  22. val = person.firstName;
  23. val = person['firstName'];
  24. val = person.age;
  25. val = person.hobbies[1];
  26. val = person.address.state;
  27. val = person.address['city'];
  28. val = person.getBirthYear();
  29.  
  30. console.log(val);
  31.  
  32. const people = [
  33. {name: 'John', age: 30},
  34. {name: 'Mike', age: 23}
  35. ];
  36.  
  37. for(let i = 0; i < people.length; i++){
  38. console.log(people[i].name);
  39. }
Add Comment
Please, Sign In to add comment