Hi..
Can I create class in JavaScript ?
Thanks...
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Javeed M ShaikhPosted Nov 2, 2011, 9:19 PM
there are no classes in JavaScript. Functions can be used to somewhat simulate classes, see example below:
function myfunc(type) {
this.type = type;
this.name = "vineet";
this.getInfo = function() {
return this.name + ' ' + this.type + ' hello';
};
}
var apple = new mydunc('corner');
apple.color = "kumar";
alert(apple.getInfo());