Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fugly JavaScript

Fugly JavaScript

Sometimes it's good to be bad. Here are some things that can optimise your JS, but that are usually handled by your compressor of choice. Understand it, but don't necessarily do it.

nefarioustim

March 26, 2012
Tweet

More Decks by nefarioustim

Other Decks in Programming

Transcript

  1. Algorithms   !   Sorts   !   Searches  

    !   Filters   !   Caching   !   Iteration   !   Recursion   !   Functional  Programming   !   Object  orientation  
  2. Falsey  and  Truthy   Falsey   !   ""  =

     false   !          0  =  false   !          undeDined  =  false   !          null  =  false   Truthy   !    "something"  =  true   !          "0"  =  true   !          1  =  true   !          -­‐1  =  true  
  3. Number   !   x  =  0   !  

    x  =  123   !   x  =  -­‐14   !   x  =  0.1541   !   x  =  NaN   !   x  =  0x1123   !   x  =  -­‐0xF1A7   !   x  =  015   [  digits  ][  .digits  ][  (  E  |  e  )  [  (  +  |  -­‐  )  ]  digits  ]   !   x  =  -­‐077   !   x  =  NaN   !   x  =  Number.MAX_VALUE  =  1.7976931348623157e+308   !   x  =  Number.MIN_VALUE  =  5e-­‐324   !   x  =  Number.NEGATIVE_INFINITY   !   x  =  Number.POSITIVE_INFINITY   !   x  =  Number.NaN  
  4. 1  0   1   1  1  0  1  0

      -­‐   64   1   32   16   8   4   2   1  0   1   1  1  0  1  0   128   64   1   32   16   8   4   2   =  181       =  -­‐53