underscorejs

class overview

  • Homework Solution
  • UnderscoreJS
  • Common Underscore Functions
  • switch 
  • Toggling Exercise

underscorejs

  • Utility library for common JavaScript operations
  • Most operations also exist in jQuery, but performance is usually better in underscore
  • Overwrites the '_' character, similar to jQuery overriding the '$' character



UnderscoreJS Homepage

common underscore functions

  • _.each() - just like $.each
  • _.keys(obj) - gets all the keys of an object
  • _.isArray(obj) - determines if an object is an array
  • _.contains() - returns true if a value is in an array
  • ...and many more!

switch

  • Common programming structure
  • Takes a single variable
  • Each case statement is a possible value in that variable
 switch(myNum) {
 case 1:
    //some code
    break;
 case 2:
    //some code
    break;
 case 3:
 case 4:
    //some code
    break;
 }
switch documentation

cool js thing for the day

Mike Bostock's Blocks
Crazy JavaScript algorithms with full code visible.
Made with Slides.com