Simple question, someone can explain this to me ?
http://jsfiddle.net/paj5c4wn/4/
// check body tagname, return bool
var check = (function ()
{
var body = /body/gi;
return function ( str )
{
return body.test( str );
}
})();
// get body element
var body = document.body;
// display result
for ( var i = 0; i < 10; i++ )
{
document.getElementById( 'result-' + i ).innerHTML = check( body.tagName );
}
with :
<p id="result-0" ></p>
<p id="result-1" ></p>
<p id="result-2" ></p>
...
do :
true
false
true
false
...
how it's possible ?