Skip to content

Instantly share code, notes, and snippets.

// Prototypeless objects in JS
var map = Object.create(null); // null has no protype or properties
"toString" in map;
// false
@tonyonodi
tonyonodi / gist:a459b13c3657cb59cf82
Created December 17, 2014 02:50
Keep things out of global scope
/* source: http://toddmotto.com/avoiding-anonymous-javascript-functions */
(function (window, document, undefined) {
// la la la
})(window, document);
@tonyonodi
tonyonodi / gist:04dcc3a12adf8105d322
Last active August 29, 2015 14:10
Javascript quine
// source code for a quine (excluding this comment).
console.log(function(string, delimiter) {return string.slice(0, -27) + delimiter + string + delimiter + string.slice(-27)}("console.log(function(string, delimiter) {return string.slice(0, -27) + delimiter + string + delimiter + string.slice(-27)}(, String.fromCharCode(34)))", String.fromCharCode(34)))
@tonyonodi
tonyonodi / gist:4b2db10170419dc5f18f
Last active August 29, 2015 14:04
Lisp like javascript
var range = function(a, b) {
var array,
direction;
array = new Array();
direction = ( b - a ) / Math.abs( b - a );
var i;
for ( i = a; i <= b; i += direction )
array.push( i );