JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
JavaScript
// simple function that takes another function
// as its parameter and then executes it.
function execute_param(func) {
func();
}
// dummy object. provided an alternative context.
obj = {};
obj.data = 10;
// no context provided
// outputs 'Window'
execute_param(function(){
console.log(this);
});
// context provided by js - Function.prototype.bind
// src: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
// outputs 'Object { data=10 }''
execute_param(function(){
console.log(this);
}.bind(obj));
// context provided by underscore - _.bind
// src: http://underscorejs.org/#bind
// outputs 'Object { data=10 }'
execute_param(_.bind(function(){
console.log(this);
},obj));
// context provided by jQuery - $.proxy
// src: http://api.jquery.com/jQuery.proxy/
// outputs 'Object { data=10 }'
execute_param($.proxy(function(){
console.log(this);
},obj));