Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ajax see 스터디 We bring e-business to your business! Javascript 작성자 : 전용우.

Similar presentations


Presentation on theme: "Ajax see 스터디 We bring e-business to your business! Javascript 작성자 : 전용우."— Presentation transcript:

1 Ajax see 스터디 We bring e-business to your business! Javascript 작성자 : 전용우

2 2 Closure (function (something){ //do something })(something); var addMethod = function(){ if(is_ie){ return function(){attachEvent….} }else{ return function(){addEventListener..} } }();

3 3 Scope 1 function method(){ this? }; document.getElementsById(“click”).onclick=method click.addEventListener("click", method, false); click.attachEvent (“onclick", method); window click element window

4 4 Scope 2 function BigComputer(answer) { this.the_answer = answer; this.ask_question = function () { alert(this.the_answer); } function addhandler() { var deep_thought = new BigComputer(42), the_button = document.getElementById('but'); the_button.onclick = deep_thought.ask_question; } deep_thought.ask_question.apply(deep_thought);

5 5 Quiz. function buildList(list) { var result = []; for (var i = 0; i < list.length; i++) { var item = 'item' + list[i]; result.push( function() {alert(item + ' ' + list[i])} ); } return result; } function testList() { var fnlist = buildList([1,2,3]); for (var j = 0; j < fnlist.length; j++) { fnlist[j](); } }

6 6 Bubbling & Capturing. bubblingcapturing

7 7 Memory leak pattern span.onclick = function() { alert(this.innerHTML); }; span -> function ->span parentDiv.appendChild(childDiv); hostElement.appendChild(parentDiv); parentDiv.appendChild(childDiv); click.attachEvent (“onclick", method); ->unload 시 click.detachEvent("onclick", method);

8 8 Tip. var obj = if(true) return a; else return b; var obj = true?a:b ; var obj = if(a) return a; else if(b) return b else return null; var obj = a||b||c; if(a){ if(b){ if(c){ return d; } var obj = a&&b&&c&&d;

9 9 performance Tip. for(var i=0,i

10 10 performance Tip. var string; for(var i=0;i

11 11 performance Tip. for(var i=0;i0;i--){ //do something; }

12 12 관심을 가지고 있는 것들.  Offline web Offline web  ReverseAjax ReverseAjax  Future web Future web

13 13 참고.  Fast javascript Fast javascript  Msdn fast Dhtml Msdn fast Dhtml  IE memory leak pattern IE memory leak pattern  Javascript scope Javascript scope  Javascript closures Javascript closures  Bubbling and capturing Bubbling and capturing Blog:mixed.tistory.com


Download ppt "Ajax see 스터디 We bring e-business to your business! Javascript 작성자 : 전용우."

Similar presentations


Ads by Google