Skip to main content

Home/ InfokeyDEV/ Group items tagged *精華*

Rss Feed Group items tagged

Benx Shen

A re-introduction to JavaScript - MDC - 1 views

  • var name = o && o.getName();
  • var name = otherName || "default";
  • The first argument to apply() is the object that should be treated as 'this'.
  • ...9 more annotations...
  • apply() has a sister function named call, which again lets you set 'this' but takes an expanded argument list as opposed to an array.
  • Closures
  • A closure is the combination of a function and the scope object in which it was created. Closures let you save state - as such, they can often be used in place of objects.
  • An unfortunate side effect of closures is that they make it trivially easy to leak memory in Internet Explorer.
  • The above code sets up the element to turn red when it is clicked. It also creates a memory leak. Why? Because the reference to el is inadvertently caught in the closure created for the anonymous inner function. This creates a circular reference between a JavaScript object (the function) and a native object (el).
  • delete el;
  • var clickHandler = function() { this.style.backgroundColor = 'red'; } (function() { var el = document.getElementById('el'); el.onclick = clickHandler; })();
  • Surprisingly, one trick for breaking circular references introduced by a closure is to add another closure:
  • It's useful to start with an idea of the language's history. JavaScript was created in 1995 by Brendan Eich, an engineer at Netscape, and first released with Netscape 2 early in 1996. It was originally going to be called LiveScript, but was renamed in an ill-fated marketing decision to try to capitalise on the popularity of Sun Microsystem's Java language — despite the two having very little in common. This has been a source of confusion ever since.
  •  
    Chinese new year animals horoscope2016 Happy Chinese new year 2016 messages & quotes Happy new year 2016 greetings for Chinese Chinese new year 2016 funny poems
  •  
    Chinese new year animals horoscope2016
    Happy Chinese new year 2016 messages & quotes
    Happy new year 2016 greetings for Chinese
    Chinese new year 2016 funny poems
Benx Shen

JavaScript call and apply - Trephine - 0 views

  •  
    Chinese new year animals horoscope2016 Happy Chinese new year 2016 messages & quotes Happy new year 2016 greetings for Chinese Chinese new year 2016 funny poems
Benx Shen

JavaScript: The World's Most Misunderstood Programming Language - 3 views

  • Why is this language so misunderstood?
  • Is JavaScript object-oriented? It has objects which can contain data and methods that act upon that data. Objects can contain other objects. It does not have classes, but it does have constructors which do what classes do, including acting as containers for class variables and methods. It does not have class-oriented inheritance, but it does have prototype-oriented inheritance.
  •  
    Chinese new year animals horoscope2016 Happy Chinese new year 2016 messages & quotes Happy new year 2016 greetings for Chinese Chinese new year 2016 funny poems
Benx Shen

Douglas Crockford's Wrrrld Wide Web - 0 views

Benx Shen

/* Position Is Everything */ - Modern browser bugs explained in detail! - 1 views

Benx Shen

John Resig - JavaScript as a Language - 2 views

  • I think we"ve seen the JavaScript language move through many individual phases: The "We need scripting for web pages" phase. (Netscape) The "We should standardize this" phase. (ECMAScript) The "JavaScript isn"t a toy" phase. (Ajax) The "JavaScript as a programming language" phase.
    • Benx Shen
       
      John Resig 認為,Javascript 歷經了這些成長階段: 1. "網頁所需的腳本(script)語言" (網景 Netscape) 2. "標準化" (ECMAScript) 3. "不只是玩具" (Ajax) 4. "成為真正的程式語言" (!?)
Benx Shen

石頭閒語:先說故事再動手設計, 從一個簡單故事看 Test Driven Development - 樂多日誌 - 0 views

  • 在進行任何程式的設計工作之前,我們必定已經知道程式的輸出入結果,亦即我們已經確知當使用者輸入什麼資料後,程式應該輸出什麼結果
  • 在 eXtreme Programming 中,我們稱這些內容為「故事 (story)」;在 RUP 中稱之為「使用案例 (use case)」;在 Microsoft Solution Framework 中稱之為「情節 (scenarios)」。
Benx Shen

無類語言的OOP(JavaScript描述)-FP-綜合技術 -JavaEye做最棒的軟件開發交流社區 - 0 views

  • 本文以 JavaScript 語言為例,介紹了無類面向對象語言中實現各種面向對象概念的方法。
  • 無類語言的OOP(JavaScript描述)
Benx Shen

胡侃:面向对象思想的进化-FP-综合技术 -JavaEye做最棒的软件开发交流社区 - 0 views

  • 面向對象編程思想的提出已經不是幾年而是幾十年了,考查其思想的變化,一方面是對現有語言的一些評判,另一方面,也算是對前輩計算機科學家的緬懷。 ——題記 Kristen Nygaard在1962年發明的 Simula 語言現在被認同為世界上第一種明確實現面向對象編程中某些"必要"元素(比如 class)的語言。Simula 是從 Algol 發展來的,可以說,是一種增加了 class 這個數據類型的 Algol,並將參數傳遞的默認模式從"按名調用"換成了"按引用調用",還提出了根據類型確定初始化過程的方法。 從 Simula 的時代開始,科學家們在解決軟件複雜度方面的思路開始"異常開闊"——當然也有資深的老派牛人們不這麼認為。比方說 Peter Norvig,寫了Design Patterns in Dynamic Programming一書來反駁。他認為設計模式早已體現在以 Lisp 為首的一批語言中了,根本不需要什麼面向對象。但我還是跟從偶像 Alan Kay 的觀點。某些時候,把一種特定的編程風格做進語言裡也是必要的。
1 - 20 of 22 Next ›
Showing 20 items per page