1 parent fcab970 commit c2f3a75Copy full SHA for c2f3a75
1 file changed
OOP/prototype.js
@@ -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
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