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

Leave a Comment