Javascript

From ITRS
Jump to: navigation, search

Tutorials

Warts

  1. Must use '===' for equality since '1' == 1 -> true
  2. '===' is "shallow", i.e. [1, 2] === [1, 2] -> false
  3. Container types don't sort lexicographically but are sorted by their string representations, ex: ['a', 2] > ['a', 10]
  4. Array(1, 2) -> [1, 2] but Array(10) allocates an array of length 10, filled with undefined.
    1. Assigning to Array.length preallocates space. Assigning length to 0 frees space.
  5. When calling functions normally 'this' is undefined in "strict mode" and window otherwise in ES5:
function f() { return this; }
f() -> window     // default
f() -> undefined  // "use strict";
  1. Dictionary (object) keys are always strings, and can't be other immutable types
  2. The boolean interpretation of some built-in types are wrong, ex: Boolean([]) -> true
  3. Broken Unicode support: https://mathiasbynens.be/notes/javascript-unicode
  4. No signed or unsigned ints, only floats. (But see the new typed arrays support)
  5. Traditionally had no byte type. (But see the new Uint8Array, ArrayBuffer from XMLHttpRequest)
  6. No natural lexical scoping, i.e. 'var' should have had 'let' semantics.

Static Analysis Tools

Frameworks

  • TodoMVC -- reviews in-browser MVC frameworks by implementing the same TODO app

See Also

Comments

blog comments powered by Disqus