Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon graphicbeacon/index.js
Last active Apr 6, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.