Skip to content

Commit f437c13

Browse files
authored
Update js codes.docx
1 parent 1df28c3 commit f437c13

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎js codes.docx‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,3 +2740,26 @@ const updated= Data.reduce((acc, item)=>{
27402740
console.log(updated)
27412741
======================================================================================================================================================================
27422742
ProtoType: If we can inherit the property of the one class to other class called as Inheritence.
2743+
2744+
const objName = {
2745+
name : "priya",
2746+
getName : function(){
2747+
return this.name; //wanted to access above name inside block so we used "this"
2748+
}
2749+
}
2750+
console.log("1",objName.getName());
2751+
2752+
const objState = {
2753+
//name: "riya",
2754+
state : "pune",
2755+
__proto__ : objName
2756+
}
2757+
console.log("2",objState.getName()); //if will find in current object, if not available then it move to upper object continuously. If still not found then it will give undefined.
2758+
2759+
const objCountry = {
2760+
name: "supriya",
2761+
country : "india",
2762+
__proto__ : objState
2763+
}
2764+
console.log("3", objCountry.getName() ,objCountry.state)
2765+
-----------------------------------------------------------------

0 commit comments

Comments
 (0)