- this 의 범위를 이용하여 공유변수등을 만들때
obj 의 this 는 obj2,obj3 에서 사용될 때 호이스트 규칙에 의해 자신 을 포함하는 객체가 된다.
var obj={
hello:function(){
return "hi,"+this.username;
},
username:"hehe"
};
var obj2={
hello:obj.hello,
username:"taeho"
};
var obj3={
hello:obj.hello,
username:"yejin"
};
console.log(obj2.hello());
console.log(obj3.hello());
2015년 3월 1일 일요일
this 에 대한 심플예제1
Related Posts:
자바스크립트의 Console 관련 메소드 유용함.https://qiita.com/ysm001/items/9abcacf74ead8a871540#consolegroup--consolegroupcollapsed--consolegroupend… Read More
Chrome 디비거 더 잘사용하기https://subicura.com/2018/02/14/javascript-debugging.html#%EB%94%94%EB%B2%84%EA%B9%85%EC%9D%B4%EB%9E%80 … Read More
JAVASCRIPT 효율적인 방법 3가지, 이벤트위임-클로저-디바운싱https://joshua1988.github.io/web-development/javascript/javascript-interview-3questions/ 이벤트리스너-클로저-디바운싱… Read More
JAVASCRIPT 유용한 함수들 -- 잘까먹거나 안썼던 것들-Array.every(function(value){ return conditional; }); : 모든 항목이 true 여야만 결과가 true 가된다.조건의 하나라도 실패하면 실패가된다. -->ex var array = [1, 3, 5, 7, 9]; array.every(function(i) { return i % 2 === 1; }); // tr… Read More
ES6 기본문법JAVASCRIPT 도 이제 파편화.... http://han41858.tistory.com/36… Read More
0 comments:
댓글 쓰기