JS OOP: 03. Property di constructor function

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Property di constructor function</title>
</head>
<body>
    <script>
        function Person() {
            // property
            this.firstName = ""
            this.lastName = ""
        }

        // instance object otomatis punya property dari Person()
        const eko = new Person();
        const budi = new Person();

        console.log(eko);
        console.log(budi);
    </script>
</body>
</html>