자바스크립트: this
자바스크립트의 this는 다른 언어의 this와 다르다고 한다. 어떻게 다를까? this에 대해 알아보자. this 자바의 this는 객체의 인스턴스가 자기 자신을 참조하는 값이다. public Class Person { String name; public Person(String name) { this.name = name; } public print() { System.out.println(this.name); } } Person p = new Person("James"); p.print(); // James언뜻 보면 자바스크립트도 비슷하게 동작한다. function Person(name) { this.name = name; } Person.prototype.print = function() { co..
자바스크립트
2021. 10. 18. 01:44