Skip to content

Commit c2f3a75

Browse files
committed
lecture 56 done
1 parent fcab970 commit c2f3a75

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

OOP/prototype.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Student(name)
2+
{
3+
this.name = name;
4+
}
5+
6+
Student.prototype.sayhello = function () {
7+
console.log("Hello");
8+
}
9+
10+
const s1 = new Student("Gulshid Zada");
11+
const s2 = new Student("Ali");
12+
13+
console.log(s1, s2);
14+
s1.sayhello();
15+
s1.sayhello();
16+
17+
18+
19+
/*
20+
Lecture # 56
21+
Topic : Prototype in JavaScript
22+
23+
Prototype Concept:
24+
Prototype is a way to share
25+
methods/functions between all objects.
26+
27+
Instead of creating the same function again
28+
and again, JavaScript stores it once in prototype.
29+
*/

0 commit comments

Comments
 (0)