f...ed by js

bug-bug-bug

by cent cent

HTML

<input type="button" id="check" value="are we f...ed?">
<div id="fckd"></div>

JavaScript

var x = {a: 1};
var tmp = '';
tmp = ('----y = x[\'b\']----')+'<br>';
var y = x['b']; //can't do x[b]
if(y)
   tmp+='f...ed!'+'<br>';
else
   tmp+='we are not f...ed!'+'<br>';
tmp+='y='+y+'<br>';
tmp+=(typeof y)+' (typeof y)'+'<br>';
tmp+=(y == undefined)+' (y == undefined)'+'<br>';
tmp+=(y === undefined)+' (y === undefined)'+'<br>';
tmp+=(y == null)+' (y == null)'+'<br>';
tmp+=(y === null)+' (y === null)'+'<br>';
tmp+='-------------------------'+'<br>';
tmp+='----z = x[\'b\']+\'\'----'+'<br>';
var z = x['b']+''; //can't do x[b]
if(z)
   tmp+='<h1>f...ed!</h1>'+'<br>';
else
   tmp+='<h1>we are not f...ed!</h1>'+'<br>';
tmp+='z='+z+'<br>';
tmp+=(typeof z)+' (typeof z)'+'<br>';
tmp+=(z == undefined)+' (z == undefined)'+'<br>';
tmp+=(z === undefined)+' (z === undefined)'+'<br>';
tmp+=(z == null)+' (z == null)'+'<br>';
tmp+=(z === null)+' (z === null)'+'<br>';
document.getElementById("check").onclick = check;
function check(){
   document.getElementById("fckd").innerHTML = tmp;
}