+ 3
object oriented javascript
Can you give me a little bit advance javascript program or project that is object-oriented? I already know the basics.
2 Réponses
+ 6
var Ronalyn={
name:"Ronalyn",
socialMedia:"Sololearn",
level:"Silver",
gender:"Female"
}
function Intro(){
console.log("Hi I'm "+this.name)
console.log("I'm using "+this.socialMedia)
console.log("I have a "+this.level+" badge")
}
Intro.call(Ronalyn)
Output
======
Hi I'm Ronalyn
Am using Sololearn
I have a silver badge.
Explanation
==========
The above code creates an object called Ronalyn with properties like
Level
Name
socialMedia
It then creates an introduction method that introduces the object.
The method is then called on the Ronalyn object, and the output is seen above
+ 2
Good example Yahiko, don't forget comma on 4th line ☺