JS Dasar: 59. Object nethod arrow function

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Object method arrow function</title>
  </head>
  <body>
    <script>
      // arrow function di object method
      const person = {
        name: "Eko",
        sayHello: (name) => {
        	console.info(this); // window
          console.info(`Hello ${name}`);
        },
      };

      person.sayHello("Budi"); // Hello Budi
    </script>
  </body>
</html>