Objects
Example:
//declare object
let video ={
title:'Loops in javascript',
videoLength : '15',
videoCreator:'Preet',
Description:'This is a Video Description'
}
console.log(video);
console.log(`Hi new video on ${video.title} is
created by ${video.videoCreator}`)
//video is the objects name and .title is its property to access
//the value of particular property
Objects with Function:
let myTodos ={
day:'Monday',
meeting:0,
meetDone:0,
addMeeting: function(num){ //addMeeting is a function name
this.meeting =this.meeting + num
//console.log(this)
//this keyword refer to current class veriable
},
Summary: function(){
return `U have ${this.meeting} of meeting today`
}
}
myTodos.addMeeting(5)//passing value
console.log(myTodos.Summary())
E
0 Comments