Skip to content

Instantly share code, notes, and snippets.

@erayarslan
Created February 24, 2016 15:34
Show Gist options
  • Select an option

  • Save erayarslan/a8eed4dcc13845f9b08a to your computer and use it in GitHub Desktop.

Select an option

Save erayarslan/a8eed4dcc13845f9b08a to your computer and use it in GitHub Desktop.
javascript function iteration
(function () {
var Next = function (arr) {
var next = function (i) {
return i != arr.length ? function () {
arr[i](next(i + 1));
} : function () {
}
};
next(0)();
};
// node.js or commonjs support
if (typeof exports !== "undefined") {
if (typeof module !== "undefined" && module.exports) {
exports = module.exports = Next;
}
exports.Next = Next;
} else {
this.Next = Next;
}
// amd support
if (typeof define === 'function' && define.amd) {
define('Next', [], function () {
return Next;
});
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment