Skip to content

Instantly share code, notes, and snippets.

@nirname
nirname / ie_iterator.js
Created Jan 18, 2013
Iterating over Arrays for IE using JQuery
View ie_iterator.js
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 Dec 11, 2015
Inject method in CoffeSrcipt using JQuery
View inject.coffee
# 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)