JS OOP: 24. Operator instanceof di inheritance
by istiq20
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Operator instanceof di inheritance</title>
</head>
<body>
<script>
class Employee {
}
class Manager extends Employee {
}
const budi = new Employee();
const eko = new Manager();
console.info(typeof budi); // object
console.info(typeof eko); // object
// operator instanceof
console.info(budi instanceof Employee); // true
console.info(budi instanceof Manager); // false
console.info(eko instanceof Employee); // true
console.info(eko instanceof Manager); // true
</script>
</body>
</html>