2014年11月2日 星期日

20141102 今日學習

每每想去找我心目中的傳奇女優的片子來看,都想不起來她的名字,在此備份
這動畫做得真好,看動畫學歷史長知識


終於一見振聾發聵呂夫子的廬山真面目 Ted x Taipei演講


今天讀到一篇文章,裡頭提到一個用JavaScript寫的數學程式庫,也提到把R語言轉換成JavaScript,這真的滿有趣的,值得一讀啊!!!
略讀了一下,恩...還在開發,不過他提到一個有趣的概念
  • JavaScript 是瀏覽器的唯一語言,而且有了 node.js 這樣的平台之後,可以通吃客戶端與伺服端兩方的應用
恩......node.js真的很重要,結論 XD。但是,人生最重要的就是那個But,既然只有JavaScript可以跟瀏覽器溝通,那Ruby到底在寫尛???

Ruby 是一種電腦程式語言,而 Rails 是一種使用 Ruby 建構出來的網站開發框架 (Web Framework),但 Rails 不是一種電腦程式語言。(當然要說 Rails 這樣的 DSL 也是一種語言也是 ok 的)
我喜歡他的結語:
“Difference between a master and a beginner? The master has failed more times than the beginner has even tried.”
“大師與新手之間的差別,就是大師失敗過的次數,比新手嘗試過的次數還多”

讀完這篇後,雖然我覺得我還是不知道Ruby在寫什麼,但是覺得早晚可能會也跑來寫寫Ruby,只學過HTML與CSS就跳槽寫Ruby,恩....誘因滿大的 XD

Ruby是一種電腦程式語言,Ruby on Rails是一種使用Ruby建構出來的網站開發框架(Web Framework)

蘇文鈺老師介紹了一本好書,馬上去圖書館預約

今日目標:
第一個paradigm之後的解釋太正了,對於object的method為何要用this而不用other name
  • If we use person.firstName and person.lastName, as in the last example, our code becomes ambiguous. Consider that there could be another global variable (that we might or might not be aware of) with the name “person.” Then, references to person.firstName could attempt to access the fistName property from the person global variable, and this could lead to difficult-to-debug errors. 
  •  So we use the this” keyword not only for aesthetics (i.e., as a referent), but also for precision.
我喜歡他對this的這段聯想
  • this can be thought of as a shortcut (or a reasonably unambiguous substitute) to refer back to the object in context (the “antecedent object”).
再來JavaScript’s this Keyword Basics這節

this這keyword的完整描述
  • The this reference ALWAYS refers to (and holds the value of) an object—a singular object—and it is usually used inside a function or a method, although it can be used outside a function in the global scope. Note that when we use strict mode, this holds the value of undefined in global functions and in anonymous functions that are not bound to any object.
再來The Biggest Gotcha with JavaScript “this” keyword這節

這節簡單來說,this雖然是一個代名詞,但他被定義好時,她裡頭並沒有value(也就是資訊),必須要等到它被調用時,才會指向一個object
  • this is not assigned a value until an object invokes the function where this is defined. 


再來The use of this in the global scope這節

這節一開頭就幫我補充了一些我沒讀過的觀念,太重要了!!!
  • In the global scope, when the code is executing in the browser, all global variables and functions are defined on the window object.
  • Therefore, when we use this in a global function, it refers to (and has the value of) the global window object that is the main container of the entire JavaScript application or web page.

緊接著上面這段話之後的paradigm真的太正了,完美解釋了上面這段話

再來When this is most misunderstood and becomes tricky這節

這節一開頭的NOTE,它介紹了我以前完全沒印象的JavaScript的觀念,context,簡單來說context就是一句話的主角
  • The context in JavaScript is similar to the subject of a sentence in English: “John is the winner who returned the money.” The subject of the sentence is John, and we can say the context of the sentence is John because the focus of the sentence is on him at this particular time in the sentence

這段話接下來的paradigm她介紹了apply的另一種用法,paradigram解釋的好清楚!!!
現在有一個object1,裡頭定義了不同的properties與method,method裡用this keyword,如果我們直接調用object1.method(),則method裡的this就會指向原本定義的object,來取得object裡的properties。若現在有另一個object2,它裡頭僅定義了與object1相同的properties名稱(沒定義method),但properties裡的value不同,那麼當我們調用object1.method.apply(object2)時,那麼我們就能讓object2調用在object1裡定義的method,來回取得object2裡的properties的value

接下來是When this is most misunderstood and becomes tricky這節的第一小節:Fix this when used in a method passed as a callback

累了,今天先到這邊,明天繼續

沒有留言:

張貼留言