-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JS-Object Oriented concepts are added
- Loading branch information
1 parent
dd9f782
commit 6796aab
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>OOJS</title> | ||
</head> | ||
<body> | ||
<center> | ||
<h1>PROTOTYPE</h1> | ||
<p>Prototype keyword - is used to create a property to an Constructor externally</p> | ||
</center> | ||
<hr> | ||
<script> | ||
function Student(){ | ||
// Local Property | ||
let name, gender; | ||
|
||
// Constructor Property | ||
this.name = "ABCD"; | ||
this.gender = "Male"; | ||
} | ||
let stud = new Student(); // Constructor object | ||
|
||
document.write("<b>Stud.name : </b>" + stud.name + "<br><br>"); | ||
document.write("<b>Stud.gender : </b>" + stud.gender + "<br><br>"); | ||
|
||
stud.age = 20; | ||
document.write("<b>Stud.age : </b>" + stud.age + "<br><br>"); | ||
|
||
let stud1 = new Student(); | ||
document.write("<b>Stud1.name : </b>" + stud1.name + "<br><br>"); | ||
document.write("<b>Stud1.gender : </b>" + stud1.gender + "<br><br>"); | ||
document.write("<b>Stud1.age : </b>" + stud1.age + "<br><br>"); | ||
|
||
Student.prototype.age1 = 30; // Defined a external property using Prototype. | ||
|
||
let student1 = new Student(); | ||
document.write("<b>student1.age1 : </b>" + student1.age1 + "<br><br>"); | ||
|
||
let student2 = new Student(); | ||
document.write("<b>student2.age1 : </b>" + student2.age1 + "<br><br>"); | ||
|
||
</script> | ||
</body> | ||
</html> |