Function with Method in JavaScript
Example
function Class(){
this.method = function(){alert('simple method')};
}
var object = new Class();
object.method();
Example with Method Speak and function person
function Person() {
this.speak =function (){
console.log ("Hello!");
}
}
var user = new Person();
user.speak();
Here speak is a method of Person function
Comments
Post a Comment