Created
October 13, 2012 06:14
-
-
Save satish860/3883471 to your computer and use it in GitHub Desktop.
Javascript Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var visitor = new customer("visitor", "vistor@gmail.com"); | |
console.log(visitor["name"]); // will log "vistor" | |
console.log(visitor.Name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Customer = function(customerName, customerEmail) { | |
this.name = customerName; | |
this.email = customerEmail; | |
this.send=function(){ | |
//send a mail using the this.email; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dynamic visitor=new customer("visitor", "vistor@gmail.com"); | |
visitor.getEmail=()=>{return this.email}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customer = function (customerName, customerEmail) { | |
this.name = customerName; | |
this.email = customerEmail; | |
this.fn = customer.prototype; | |
this.extend = function (obj) { | |
for (var i in obj) { | |
customer[i]=obj[i] | |
} | |
}; | |
this.Include = function (obj) { | |
for (var i in obj) { | |
this.fn[i] = obj[i] | |
} | |
} | |
}; | |
var visitor = new customer("visitor", "vistor@gmail.com"); | |
vistor.extend({ | |
getEmail: function () { | |
return this.email; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vistor.Include({ | |
getEmail: function () { | |
return this.email; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vistor = new customer("vistor", "vistor@gmail.com"); | |
console.log(vistor.name) // this is not a private variable. ooch!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var visitor = new customer("visitor", "vistor@gmail.com"); | |
visitor.getEmail=function(){ | |
return this.email; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Customer = function(customerName, customerEmail) { | |
var name = customerName; | |
var email = customerEmail; | |
this.send=function(){ | |
//send a mail using the this.email; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Customer = function(customerName, customerEmail) { | |
var name = customerName; | |
var email = customerEmail; | |
this.send=function(){ | |
//send a mail using the this.email; | |
} | |
}; | |
customer.prototype.getEMail=function(id){ | |
return this.email; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment