JavaScript idioms you need to know

  • Everything in JavaScript is an Object. Even functions
  • Every object is always mutable
  • The dot operator is equivalent to de-referencing by hash (e.g., foo.bar === foo["bar"])
  • The new keyword creates an object that class constructors run inside of, thereby imprinting them
  • Functions are always closures (combine w/ previous rule to create OOP)
  • The this keyword is relative to the execution context, not the declaration context
  • The prototype property is mutable

来自 http://alex.dojotoolkit.org/?p=535

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: