Skip to content

Instantly share code, notes, and snippets.

@screamy
Forked from padolsey/1.js
Last active December 14, 2015 03:09
Show Gist options
  • Save screamy/5019205 to your computer and use it in GitHub Desktop.
Save screamy/5019205 to your computer and use it in GitHub Desktop.
/x/==x
var x = '/x/';
x() === x()() === x()()()
for first comparison should be returned the same value
for second - true
function x () {
x.times = ++x.times || 1;
return x.times > 5 ? true : x;
}
x() === x()() === x()()()
x > 2 && x < 2
valueOf property should be overwritten to cast object to primitive
var x = {
reverse: -1,
val: -10,
valueOf: function () {
this.val = this.reverse * this.val;
return this.val;
}
}
delete x.a && x.a;
x[x]==x
var x = {}
x["[object Object]"] = x
typeof new x < typeof x
typeof return as result string, charCodeAt using for string comparison
function x () {
x = 1;
return function () {};
}
x - 1 === x + 1
var x = {
val: -1,
valueOf: function () {
return (this.val = ~this.val + 1);
}
};
/*
var x = {
times: 0,
valueOf: function () {
++this.times;
return this.times%2 ? 1 : -1;
}
};
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment