How should we use this and new keywords in javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How should we use this and new keywords in javascript?

function Person(name,age,std){ this.studname=name; this.studage=age; this.studstd=std; } var student1 = new Person("alpha",20,5); var student2= new Person("Omega",21,10); document.write(student1.name+"is studying in"+student1.std+"but"+student2.name+"is good"); Is this right?

2nd Jul 2020, 9:29 AM
C Alpha Beraka
C Alpha Beraka - avatar
1 Answer
0
I think the code is right, but I didn't understood the question 🤔
2nd Jul 2020, 6:43 PM
Lorenzo Parisi
Lorenzo Parisi - avatar