Skip to content

Instantly share code, notes, and snippets.

@gbradley
Forked from padolsey/1.js
Last active December 14, 2015 02:48
Show Gist options
  • Select an option

  • Save gbradley/5016026 to your computer and use it in GitHub Desktop.

Select an option

Save gbradley/5016026 to your computer and use it in GitHub Desktop.
var x = '/x/';
/x/==x
function x(){
return ++x.i < 6 ? x : true;
}
x.i=0;
x() === x()() === x()()()
var x = {
i : false,
toString: function(){
this.i = !this.i;
return this.i ? 3 : -3;
}};
x > 2 && x < 2
/*var X = function(){};
Object.defineProperty(X.prototype, "a", {
get : function(){
return true;
}
});
var x = new X();*/
function X(){}
X.prototype.a = true;
var x = new X();
delete x.a && x.a;
/*var x = '0';*/
var x = {};
x["[object Object]"] = x;
x[x]==x
var x = function(){
x = '';
};
typeof new x < typeof x
var x = Infinity;
x - 1 === x + 1
@padolsey

Copy link
Copy Markdown

Nice work!! Object.defineProperty is ES5 though D:

@gbradley

Copy link
Copy Markdown
Author

Curses! Real solution was much simpler :)

@getify

getify commented Feb 22, 2013

Copy link
Copy Markdown

Sorry to bust another bubble, but your solution to 5.js also relies on non-ES5 (the array-access to characters of strings wasn't added officially until ES5 and doesn't work in several ES3 browsers).

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String#section_5

:)

@getify

getify commented Feb 22, 2013

Copy link
Copy Markdown

...but i definitely prefer your solution to 6.js to mine. same idea, your's is simpler. :)

@aborjinos

Copy link
Copy Markdown

for 2.js I would suggest

function x() {
return x;
}

x() === x()()()()()()()()()()()()()(); // true

@getify

getify commented Feb 22, 2013

Copy link
Copy Markdown

@aborjinos -- but that misses the spirit of that question...

x() === x()() === x()()()

Your proposed solution would be insufficient because this would fail, because the first assignment results in a boolean true, and so the second comparison would fail because true !== function.

@aborjinos

Copy link
Copy Markdown

@getify -- yeah you are right

so I can add 8.js :)

if the following is true what is x?
x(x) === x(x)(x)(x)

@getify

getify commented Feb 22, 2013

Copy link
Copy Markdown

@aborjinos -- function x(y) { return y; }

@gbradley

Copy link
Copy Markdown
Author

@getify - damn you're right. Updated now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment