Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. this.age = 8
  2. this.name = "Steve"
  3.  
  4. manAttributes = ["age","name"]
  5.  
  6. console.log(Human.manAttributes[0])
  7.  
  8. var human = {
  9.  
  10. name: "Smith",
  11. age: "29"
  12.  
  13. };
  14.  
  15.  
  16. var manAttributes = ["age","name"];
  17.  
  18. for(var prop in manAttributes){
  19. if(human.hasOwnProperty(manAttributes[prop])){
  20. console.log(manAttributes[prop] + ": "+human[manAttributes[prop]]);
  21. }
  22. }
  23.  
  24. var Human = {
  25. manAttributes: ["age","name"],
  26. age: 8
  27. };
  28. alert(Human[Human.manAttributes[0]]); //alerts 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement