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




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;
 }

cool js thing for the day

Crazy JavaScript algorithms with full code visible.

AJS Lecture 13: UnderscoreJS

By Ryan Lewis

AJS Lecture 13: UnderscoreJS

  • 581