Skip to content

Instantly share code, notes, and snippets.

@satish860
Created October 13, 2012 06:14
Show Gist options
  • Save satish860/3883471 to your computer and use it in GitHub Desktop.
Save satish860/3883471 to your computer and use it in GitHub Desktop.
Javascript Class
var visitor = new customer("visitor", "vistor@gmail.com");
console.log(visitor["name"]); // will log "vistor"
console.log(visitor.Name);
var Customer = function(customerName, customerEmail) {
this.name = customerName;
this.email = customerEmail;
this.send=function(){
//send a mail using the this.email;
}
};
dynamic visitor=new customer("visitor", "vistor@gmail.com");
visitor.getEmail=()=>{return this.email};
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;
}
});
vistor.Include({
getEmail: function () {
return this.email;
}
});
var vistor = new customer("vistor", "vistor@gmail.com");
console.log(vistor.name) // this is not a private variable. ooch!!
var visitor = new customer("visitor", "vistor@gmail.com");
visitor.getEmail=function(){
return this.email;
}
var Customer = function(customerName, customerEmail) {
var name = customerName;
var email = customerEmail;
this.send=function(){
//send a mail using the this.email;
}
};
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