My question has to do with understanding how classes assign values to properties and how objects are instantiated in Javascript. I would like to understand more how this process works.
If I create two classes where the second inherits from the first
class A {
name
constructor(name){
this.name = name
}
}
class B extends A {
name
status
constructor(name, status){
super(name)
this.status = status
}
}
And then create an instance of class B, when I print it to the console
x = new B('myClass', true)
console.log(x)
It prints that the name variable is undefined
B { name: undefined, status: true }
I'm pretty sure that the name property in B is over-writing the name property in A, but why doesn't the A constructor assign the new name variable to be the value passed into it?