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

Popular posts from this blog

পিৎজা এবং বই

How to Download Video from Youtube - The Easiest way