Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Last active April 6, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicbeacon/62ce26a0d50288d330cf8700b75ee9c0 to your computer and use it in GitHub Desktop.
Save graphicbeacon/62ce26a0d50288d330cf8700b75ee9c0 to your computer and use it in GitHub Desktop.
Snippet examples from wtfjs.com
// https://wtfjs.com/wtfs/2015-04-08-array-sort
console.log([1, 2, 3, 15, 30, 7, 5, 45, 60].sort());
// https://wtfjs.com/wtfs/2015-03-23-adding-arrays
console.log([1, 2, 3] + [4, 5, 6]);
// https://wtfjs.com/wtfs/2014-02-22-wtf_document.all
console.log(document.all);
console.log(document.all[0]);
console.log(typeof document.all);
console.log(!{});
console.log(!document.all);
// https://wtfjs.com/wtfs/2014-03-13-regex-test-true-false
var re = new RegExp('Foo B', 'gi');
console.log(re.test('Foo Bar'));
console.log(re.test('Foo Bar'));
// https://wtfjs.com/wtfs/2013-08-07-Math.max()-behaviour
console.log(Math.max(3, 0));
console.log(Math.max(3, {}));
console.log(Math.max(3, []));
console.log(Math.max(3, true));
console.log(Math.max(3, 'foo'));
console.log(Math.max(-1, null));
console.log(Math.max(-1, undefined));
// https://wtfjs.com/wtfs/2011-09-24-Date-silently-accepts-anything
var d = new Date("couldn't you please throw an exception here instead?");
console.log(d.getTime());
var e = new Date();
console.log(e.toString());
console.log(e.getMonth());
// https://wtfjs.com/wtfs/2010-02-12-null-is-not-an-object
console.log(typeof null);
console.log(null instanceof Object);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment