Es6_classes prototypes and __proto__ problems

/*Now we will be implementing real classes using class ad we will see it’s going to give the same results
as we are getting while implementing using the functions */
class Person{
constructor(name,age){
this.name = name
this.age = age
}
}

let p = new Person(‘Harry Potter’,15)
let p2 = new Person(‘John Doe’,30)

console.log(p.proto == Person.prototype)
console.log(typeof Person)/*Internally it is still a function, the working of it still remains the same
Here still it used the prototype, all the objects of it are inherited from the prototype */

/*Only 2 difference are that we canot call the class WITHOUT using the new keyword, also we use class and
constructor keyword(explicitly)

Another difference is we can extend the class
*/

class Student extends Person{
constructor(name,age,school){
super(name,age)//super calls the parent class constructor and passes the name,age
this.school = school
}
}

let s = new Student(‘Ron Welsely’,16,‘Hogwarts’)

console.log§
console.log(s)

console.log(Student.proto == Person)//True

console.log(Person.prototype.isPrototypeOf(s))
//Why is it true and why Student.proto == Person instead of Student.proto == Person.prototype
???

Student.__proto__ == Person implies that Student inherits from Person. This also explains Person.prototype.isPrototypeOf(s) == true
For more details, read this article https://medium.com/code-monkey/javascript-classes-and-prototypal-inheritance-2a53ed7343d8

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.