Javascript-Classes - (5)
👉Classes
✅Classes are functions
To create a class in javascript, function has to be created. Though new javascript specifications introduced "class" keyword, it uses function internally.
We can also create properties and methods within class.
function customer ({
this.CustomerCode = "1001";
this.CustomerName = "John";
this.getFullDetails = function(){
return this.CustomerCode + " " + this.CustomerName";
}
})
This is the basic syntax of class and it doesn't respect OOPs principles. Variables are attached to the windows object, hence the properties are global not private.
Comments
Post a Comment