Home
<!DOCTYPE html> <html> <body> <h1>Demo: Prototype</h1> <script> function Student() { this.name = 'John'; this.gender = 'M'; } Student.prototype.age = 15; var studObj1 = new Student(); alert(studObj1.age); var studObj2 = new Student(); alert(studObj2.age); </script> </body> </html>
Result: