Skip to content

Commit 96da216

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

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎js codes.docx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,3 +2763,24 @@ const objCountry = {
27632763
}
27642764
console.log("3", objCountry.getName() ,objCountry.state)
27652765
-----------------------------------------------------------------
2766+
2767+
Array.prototype.convertToObject = function(){
2768+
let newObj ={}
2769+
this.forEach( ele =>{
2770+
newObj[ele]= ele;
2771+
}
2772+
)
2773+
return newObj;
2774+
}
2775+
const arr =["priya"];
2776+
console.log(arr.convertToObject()); //array to object conversion with prototype
2777+
------------------------------------------------------------------
2778+
function myProtoType(name){
2779+
return this.name=name;
2780+
}
2781+
myProtoType.prototype=objName;
2782+
const myproto = myProtoType("priya")
2783+
console.log(myproto);
2784+
console.log(myproto.getName());
2785+
==========================================================================================================================================================================
2786+

0 commit comments

Comments
 (0)