JS OOP: 14. Class property
by istiq20
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Class property</title>
</head>
<body>
<script>
class Person {
constructor(name) {
// property
this.name = name;
}
}
const eko = new Person("Eko");
console.info(eko);
console.info(eko.name); // Eko
const budi = new Person("Budi");
console.info(budi);
</script>
</body>
</html>