Skip to content

Instantly share code, notes, and snippets.

@SergeyNarozhny
Last active August 29, 2015 14:27
Show Gist options
  • Save SergeyNarozhny/c70ef61989ace9df627c to your computer and use it in GitHub Desktop.
Save SergeyNarozhny/c70ef61989ace9df627c to your computer and use it in GitHub Desktop.
// [1,2,3,4,5].duplicator()
Array.prototype.duplicator = function() {
var arr = this;
if (!this.length) return;
Array.prototype.map.call(this, function(el){ arr.push(el); });
return arr;
}
// sum(1)(2)(3)();
function sum(x) {
return function(y) {
if (!y) return x;
else return sum(x + y);
};
}
// a.b.c.d -> a: { b: { c: { d: null}}}
var n = "a.b.c.d",
z = n.split("."),
s = {};
function gi(obj){
var o = Object.getOwnPropertyNames(obj);
if (o.length && Object.getOwnPropertyNames(obj[o]).length)
return gi(obj[o]);
else
return o.toString();
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment