JSFiddle - React, Tailwind, and code Playground
by meetravi
HTML
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<h2 id="heading"> Underscore Js Examples </h2>
<br/>
<button id="underscore_button">Click Here</button>
JavaScript
$(document).ready(function(){
// Each Iterating the list of items
// _.each([1, 2, 3], function(num){ alert(num); });
/*
Produces a new array of values by mapping each value in list through a transformation function (iterator). If the native map method exists, it will be used instead. If list is a JavaScript object, iterator's arguments will be (value, key, list).
*/
//_.each({'one':'[1,2,3]','two':'2','three':'3'},function(value,key){alert(value+":"+key);})
//_.map([1, 2, 3], function(num){ alert(num*3); });
/*var calculateCircleArea = function(radius){
var area = 22/7*radius*radius;
alert('area value='+area);
};
calculateCircleArea = _.bind(calculateCircleArea,{'name':'test'},'5');
calculateCircleArea();*/
var buttonView = {
label : 'underscore',
onClick : function(){ alert('clicked: ' + this.label); },
onHover : function(){ alert('hovering: ' + this.label); }
};
_.bindAll(buttonView);
$('#underscore_button').bind('click', buttonView.onClick);
$('#heading').bind('click', buttonView.onHover);
});