Skip to content

Instantly share code, notes, and snippets.

@nirname
nirname / ie_iterator.js
Created January 18, 2013 08:17
Iterating over Arrays for IE using JQuery
if (typeof Array.prototype.indexOf == "undefined") {
Array.prototype.indexOf = function(value) {
for (var i = 0; i < this.length; i++) {
if (this[i] == value) {
return i;
}
}
return -1;
}
}
@nirname
nirname / inject.coffee
Last active December 11, 2015 06:58
Inject method in CoffeSrcipt using JQuery
# inject function
inject = (collection, object, handler)->
$.each collection, (index, value)->
object = handler(object, value)
true
object
# the same as a method
inject_method = (object, handler)->
inject(this, object, handler)