This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //don't slice arguments just to iterate | |
| //http://jsperf.com/handle-args | |
| (function () { | |
| var i, len; | |
| for (i = 0, len = arguments.length; i < len; i += 1) { | |
| console.log(arguments[i], i); | |
| } | |
| }(3, 2, 1)); | |
| //don't prepend arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ED = ED || {}; | |
| // Utility functions | |
| ED.util = (function() { | |
| // Data structure functions | |
| function each(object, callback) { | |
| if (object === null) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPrecision(num) { | |
| var split = (num + "").split(/([\.e\-]{1,2})/); | |
| var i, len, token, next, nextNum, precision; | |
| for (precision = 0, i = 1, len = split.length; i < len; i += 1) { | |
| token = split[i]; | |
| next = split[i + 1]; | |
| nextNum = +next; | |
| if (token === ".") { | |
| precision += next.length; | |
| } else if (token === "e-") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * null-safe retrieval of objects and their property values from context | |
| * @function get | |
| * @param {String|String[]} path | |
| * @param {Object} [obj=this] | |
| * @return | |
| */ | |
| (function (HEAD) { | |
| var depthCache = {}; | |
| var cache = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var each = (function () { | |
| function each(arr, fn) { | |
| var len = arr.length; | |
| return (each[len] || (each[len] = each.factory(len), each[len]))(arr, fn); | |
| } | |
| each.factory = function (len) { | |
| var body = "\tvar i = 0;\n"; | |
| while (len--) { | |
| body += "\tfn(i, arr[i++]);\n"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.merge = function (/*Array1, ..., ArrayN*/) { | |
| this.push.apply(this, arguments.length > 1 ? arr.concat.apply([], arguments) : arguments[0]); | |
| return this; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (namespace) { | |
| "use strict"; | |
| function Class() {} | |
| Class.prototype = { | |
| constructor: Class | |
| }; | |
| Class.extend = function (fn) { | |
| if (!fn.name) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createAspect(fn) { | |
| var _1 = jQuery.Callbacks(), | |
| _2 = jQuery.Callbacks(), | |
| _3 = jQuery.Callbacks(), | |
| args, result; | |
| function aspect() { | |
| args = arguments; | |
| _2.fireWith(this, args); | |
| return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //http://stackoverflow.com/a/2687693/450808 | |
| //http://dochub.io | |
| //https://github.com/pamelafox/teaching-materials | |
| //http://www.codecademy.com/tracks/javascript-combined | |
| //http://stackoverflow.com/questions/11246/best-resources-to-learn-javascript | |
| //http://bonsaiden.github.com/JavaScript-Garden/ | |
| //http://learn.appendto.com/ | |
| //http://net.tutsplus.com/tutorials/javascript-ajax/the-best-way-to-learn-javascript/ | |
| //http://rmurphey.com/blog/2010/09/15/in-search-of-javascript-developers-a-gist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Plinko() { | |
| this.tree = {}; | |
| } | |
| Plinko.prototype.add = function (from, fn) { | |
| var leaf, | |
| callback; | |
| if (typeof from === "string") { | |
| leaf = from; | |
| callback = fn; | |
| } else { |
OlderNewer