5. Console.log Test

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Hello World</title>
  </head>
  <body>
    <h1>Hello World</h1>
    <p>안녕하세요! HTML5</p>
  </body>
</html>

const o = { foo: 1 };
console.log('[test]', o);
console.log('[test2]', o, 'hi');
console.log(1 + 2);
console.log(null);
console.log(undefined);
console.log([]);
var arr = [1, 2, 2, 3];
console.log(arr.indexOf(2));    // 1
console.log(arr.indexOf(4));    // -1
console.log(arr.indexOf(2, 2)); // 1

function Person(name) {
  this.name = name;
}

var foo = new Person('Lee');

console.dir(Person); // prototype 프로퍼티가 있다.
console.dir(foo);    // prototype 프로퍼티가 없다.

// Class
class Person1 {
  constructor(name) {
    this._name = name;
  }

  sayHi() {
    console.log(`Hi! ${this._name}`);
  }
}

const me = new Person1('Lee');
me.sayHi(); // Hi! Lee

console.log(me instanceof Person1); // true


      
Back to top