Coder Social home page Coder Social logo

f2e-technote's People

Contributors

akayhu avatar aldy120 avatar dazedbear avatar derekhung avatar jerryliu318 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

f2e-technote's Issues

this 的觀念有誤

this 在function 的時候取決於他是怎麼被『呼叫執行』的

例如:一般function

var a = function() { console.log(this)}
a();

// window

這邊你可以把他想成 window.a() 因此是由window來呼叫a 這個function
這時候this 就會指向window

var b = { a:function(){ console.log(this) }}
b.a();

// b:{ a.....}

其實對照上面就很清楚了,這時候就變成b 在執行這個function 因此很自然的this 就指到了b

而constructor (new) 為何不一樣?因為constructor 他會自己先產生一個空物件,然後讓這個空物件去執行他的constructor函式,做完constructor function 之後再賦值給宣告,如下

var a = function(){ console.log(this)}
var con = new a();
==> {}.a()
==> con = {} // constructor temp object

// con: {}

忽略YUI

YUI 與 Lab.js 其實已經是作古的script
之後可以忽略這兩個library進行研究喔!

早期的js 書籍都是yahoo 當初實作YUI的那群人所編撰,因此範例都會使用YUI來講,但YUI已經停止維護更新了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.