Null [object Object]
-
[code]
//i just want my motherfucking potatoes.
Object.prototype.toString = function(){ return "[object Potato]"; }; Object.prototype.toString.call(new Potato).slice(8,-1);
>"Potato"
[/code]Ouch, though...
> Object.prototype.toString = function(){ return "[object Potato]"; }; Object.prototype.toString.call(new Potato).slice(8,-1); 'Potato' > realTypeOf("") 'Potato' > realTypeOf(1) 'Potato' > realTypeOf(null) 'Potato' >
-
Just for you and @ben_lubar:
fixed all y'all shit[code]
function toString(){};
toString.prototype.toString = Object.prototype.toString;
Object.prototype.toString = function () {
'use strict';
var r = toString.prototype.toString.call(this);
if(r == "[object Object]") {
if(this._stackoverflow)
return r;
this._stackoverflow = true;
return this.toString();
}
return r;
}
function Potato(){};
Potato.prototype.toString = function(){ return "[object Potato]"; }
[/code]and now you get:[code]
Object.prototype.toString.call(3);"[object Number]"
[/code][code]
Object.prototype.toString.call(undefined);
"[object Undefined]"
[/code][code]
Object.prototype.toString.call(new Potato);
"[object Potato]"
[/code][code]
Object.prototype.toString.call(Potato);
"[object Function]"
[/code][code]
Object.prototype.toString.call(function(){});
"[object Function]"
[/code][code]
function NotAPotato(){};
Object.prototype.toString.call(new NotAPotato);
"[object Object]"
[/code]
[code]
NotAPotato.prototype.toString =
function() {
return "[object ScrewOffWeCanDoWhatWeWant]";
}
Object.prototype.toString.call(new NotAPotato);
"[object ScrewOffWeCanDoWhatWeWant]"
[/code]
-
granted, now i've trashed the _stackoverflow property
[code]
var a = new Potato();
Object.prototype.toString.call(a);"[object Potato]"
a;
Potato {_stackoverflow: true, toString: function}
[/code]
-
Annnnnnd more null bugs, dicsourse shat bricks on itself after I posted:
After what you've been doing in the console though, not sure if we can blame discourse for this one
-
Also, interesting that <pre> in a <code> kills the background color
A mixture of at least three different formatting systems, all of which have slightly different appearances.
Elsewhere, and independently, this was also noticed. And somewhat mitigated.
http://what.thedailywtf.com/t/code-testing/8103
Making subsequent conversations from the above two quotes somewhat amusing to anyone else coming in afterwards...
-
After what you've been doing in the console though, not sure if we can blame discourse for this one
well, I did say it was a bad idea to override the base Object's toString implementation, didn't I?
My last version doesn't kill Dicsourse (at least not the posting part), so that's something. Though I believe last night I was running all of the codes against a console spawned from a separate and empty window specifically to have a blank slate playground, so it shouldn't have interfered with Dicsourse's posting functionality at all.
-
bump
Still happening; I know I've seen it today.
-
Run it in a web worker!