What would be the output? [JavaScript Inheritance]

@Yomesh Gupta

Let us talk about JavaScript Inheritance today. This is an interesting question that I recently came across.

What do you think would be the output of the following code snippet?

class Person {
	constructor(name) {
		this.name = name;
	}

	print = () => {
		console.log(this.name);
	}
};

class Employee extends Person {
	constructor(name, id) {
		super(name);
		this.id = id;
	}

	print() {
		console.log(this.name, this.id);
	}
};

const one = new Person('one');
one.print();

const two = new Employee('two', 2);
two.print();
Option 1
one
two
Option 2
one
two 2
Option 3
one
undefined undefined
Option 4
one
undefined 2
Option 5
Uncaught Error