ivapopova

object_vs_array.js

Jan 24th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let student = [
  2.     "Pesho",
  3.     "Ivanov",
  4.     [4,5,6],
  5.  
  6.     function(){
  7.         console.log(`Hi I'm ${student[0]}`);
  8.     },
  9.     function(){
  10.         console.log(`${student[0]} is going to school`);
  11.     },
  12. ]
  13.  
  14. let studentObj = {
  15.     firstName:"Pesho",
  16.     lastName:"Ivanov",
  17.     scores:[4,5,6],
  18.  
  19.     greet: function(){
  20.         console.log(`Hi I'm ${studentObj.firstName}`);
  21.     },
  22.     goToSchool:function(){
  23.         console.log(`${studentObj.firstName} is going to school`);
  24.     },
  25. }
  26.  
  27.  
  28. console.log(studentObj.greet());
Advertisement
Add Comment
Please, Sign In to add comment