Hi..
Can I create class in JavaScript ?
Thanks...
Class in JavaScript
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 2, 2011, 5:19 PM EDT
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());