Skip to content

Instantly share code, notes, and snippets.

@cope
Forked from artalar/wtf.js
Last active February 4, 2019 12:53
Show Gist options
  • Save cope/40e7f2ee216babafc804a49dcbc9325b to your computer and use it in GitHub Desktop.
Save cope/40e7f2ee216babafc804a49dcbc9325b to your computer and use it in GitHub Desktop.
/* VT100 terminal reset (<ESC>c) */
console.log('\033c');
/* numbers comparations */
/**/ [2] == 2;
//// true
/**/ [] + [];
//// ''
/**/ [] == [];
//// false
/**/ typeof [];
//// 'object'
/**/ [] == ![];
//// true
/**/ +[] == +![];
//// true
/* null comparation */
/**/ 0 > null;
//// false
/**/ 0 >= null;
//// true
/**/ 0 == null;
//// false
/**/ 0 <= null;
//// true
/**/ 0 < null;
//// false
/**/ typeof null;
//// 'object'
/**/ null instanceof Object;
//// false
/* math */
/**/ 999999999999999;
//// 999999999999999
/**/ 9999999999999999;
//// 10000000000000000
/**/ -9999999999999999;
//// -10000000000000000
/**/ 0.1 + 0.2 == 0.3;
//// false
/**/ 0.1 + 0.2;
//// 0.30000000000000004
/**/ 3 > 2 > 1;
//// false
/**/ 3 > 2 >= 1;
//// true
/**/ 1/0;
//// Infinity
/**/ typeof Infinity;
//// 'number'
/**/ 1/0;
//// Infinity
/**/ 1/-0;
//// -Infinity
/**/ Infinity == -Infinity;
//// false
/**/ Number.MAX_VALUE;
//// 1.7976931348623157e+308
/**/ Number.MIN_VALUE < 0;
//// false
/**/ Number.MIN_VALUE;
//// 5e-324>
/**/ Math.max() > Math.min();
//// false
/**/ Math.max();
//// -Infinity
/**/ Math.min();
//// Infinity
/* string */
/**/ 'wtf' instanceof String;
//// false
/**/ String('wtf') === new String('wtf');
//// false
/**/ new String('wtf');
/* { '0': 'w',
'1': 't',
'2': 'f' } */
/**/ new String('wtf').toString();
//// 'wtf'
/* NaN */
/**/ typeof NaN;
//// 'number'
/**/ NaN == NaN;
//// false
/* construct function */
/**/ new 0xff.constructor.constructor('console.error("WTF")')();
//// WTF
/**/ new Function('console.error("WTF")')();
//// WTF
/* typeof/instanceof */
/**/ Array instanceof Array;
//// false
/**/ new Array instanceof Array;
//// true
/**/ Math instanceof Math;
/* TypeError: Expecting a function in instanceof check, but got #<Object>
at repl:1:18
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:203:10)
at Interface._line (readline.js:532:8)
at Interface._ttyWrite (readline.js:761:14)
at ReadStream.onkeypress (readline.js:100:10)
at ReadStream.emit (events.js:98:17)
at emitKey (readline.js:1096:12) */
/* finally */
/**/ let count = 0;
/**/ function foo() {
/**/ try { return 999; }
/**/ finally { return ++count; } }
/**/ console.log(foo(), count);
//// 1 1
/* new line */
/**/ function sum(a, b) {
/**/ return
/**/ a + b; }
/**/ console.log(sum(1, 3));
//// undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment