0
Is sololearn wrong to use var instead of Const or let during creation of a new object
function Human(name, age, race) { this.name = name; this.age = age; this.race = race; } var X = new Human('Alex', 20, 'African'); Const X = new Human('Alex',20,'African'); Let X = new Human ('Alex',20,'African'); console.log(X.name); //Which of the three is correct?//
3 Respuestas
+ 6
var is the old way of declaring variables. There is still a lot of old Javascript code out there, written before const and let were added to the language. So you need to know how it works, what are its limitations and gotcha's.
But when writing new code, you really should use let and const.
https://javascript.info/variables
0
Yeap. Many of the solutions and lessons are wrong/bad code and I'm starting to feel like this site is hindering my progress.