The underscore.js JavaScript library provides us with a huge set of functions we usually find in functional programming languages.
The following code sample shows how simple it is to use this library. If you try to run this code on your end make sure you update the link for the underscore-min.js file.
<!DOCTYPE html> <html> <head> <title>underscore demo</title> <script type="text/javascript" src="underscore-min.js"> </script> </head> <body> <script type="text/javascript"> vec = [1970,2012,1982,1998]; _.each(vec,function(num){document.writeln("<br/>"+num)}); </script> </body> </html>
The following video clip shows the execution of this code sample and explains it. You can find more video clips for learning how to use this library in my dedicated youtube playlist for underscore.js.
You can find more video clips, code samples and training material for learning how to use this library in my free (for personal use) Underscore.js Basics course at http://abelski.lifemichael.com.