JavaScript Variable Declaration

JavaScript Variable Declaration

I am new to JavaScript, but familiar with a variety of other languages. I don’t quite understand what the following variable declarations do:

ns4 = (document.layers)? true:falseie4 = (document.all)? true:false

Is it just setting up a boolean variable?

Yes, those are just boolean values.

This is the same thing as saying:

if (document.layers) {    ns4 = true}else {    ns4 = false}

However, keep in mind that the next version of Netscape won’t support document.layers or document.all, so both of these fields will be set to false.


Share the Post: