anonymous coward anonymous coward - 2 months ago 26
Javascript Question

Why is `document.all` falsy?

is a non-primitive object in the DOM that is falsy.

For example, this code doesn't do anything:

if (document.all) {

Can someone explain why this is?


document.all is available only on Internet Explorer, webkit and Opera.

On every other browser all is an undefined property of document object (and undefined is considered as a false value)

As historical note: many (really many) years ago document.all was used to tell Internet Explorer from Netscape Navigator so if you meet a script that is checking if (document.all) ... I strongly suggest to find a better script :)