How to declare an object in javascript?
- by admin
- 0
How to declare classes in jaascript?
Objects are building blocks of javasript. “Class” keyword not using in javascript. Its all about objects.
Two methods are there:
literal object.
1.var myobj={
fname:”joe”,//Property
lname:”john”,//Property
fullname: function (){
console.log(this.fname +” ” + this.lname);
}
}
we can access the properties through the methods used inside the objects, couldn’t call properties directly as myobj.fname;
Javascript constructor.
2. function myobjs(){
this.name= “john”; //Property
this.age= “20”; //Property
this.nameandage= function(){ // Method
console.log(this.name+’with age’+this.age);
}
}
How to declare classes in jaascript? Objects are building blocks of javasript. “Class” keyword not using in javascript. Its all about objects. Two methods are there: literal object. 1.var myobj={ fname:”joe”,//Property lname:”john”,//Property fullname: function (){ console.log(this.fname +” ” + this.lname); } } we can access the properties through the methods used inside the objects, couldn’t…
How to declare classes in jaascript? Objects are building blocks of javasript. “Class” keyword not using in javascript. Its all about objects. Two methods are there: literal object. 1.var myobj={ fname:”joe”,//Property lname:”john”,//Property fullname: function (){ console.log(this.fname +” ” + this.lname); } } we can access the properties through the methods used inside the objects, couldn’t…