Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Where or what is here the condition

jabojabo Posts: 7Member
Learning about JavaScript I have all sorts of problems, which I don't unterstand.
For instance,I found in a program the following:

if (document.all){
var wide = window.screen.availWidth;
var high = window.screen.availHeight;
}

Now.
All the books say that the SYNTAX for IF is

if(condition){
statement(s) if true
}

But in this case it is written

if(document.all).


Is that a condition?


If yes, what condition is it then?
Could anybody give me a hint, please,
what that condition could be?

Thank you!
Jabo

Jabo

Comments

  • christopherNchristopherN Posts: 4Member
    the SYNTAX that they book shows is just a prototype for the format, where (condition) is any condition. The snippet that you provided seems to check that the document is loaded [condition will return an object], and then assigns the values to the variables.

    : Learning about JavaScript I have all sorts of problems, which I don't unterstand.
    : For instance,I found in a program the following:
    :
    : if (document.all){
    : var wide = window.screen.availWidth;
    : var high = window.screen.availHeight;
    : }
    :
    : Now.
    : All the books say that the SYNTAX for IF is
    :
    : if(condition){
    : statement(s) if true
    : }
    :
    : But in this case it is written
    :
    : if(document.all).
    :
    :
    : Is that a condition?
    :
    :
    : If yes, what condition is it then?
    : Could anybody give me a hint, please,
    : what that condition could be?
    :
    : Thank you!
    : Jabo
    :
    : Jabo
    :


  • hsk14hsk14 Posts: 10Member
    : Learning about JavaScript I have all sorts of problems, which I don't unterstand.
    : For instance,I found in a program the following:
    :
    : if (document.all){
    : var wide = window.screen.availWidth;
    : var high = window.screen.availHeight;
    : }
    :
    : Now.
    : All the books say that the SYNTAX for IF is
    :
    : if(condition){
    : statement(s) if true
    : }
    :
    : But in this case it is written
    :
    : if(document.all).
    :
    :
    : Is that a condition?
    :
    :
    : If yes, what condition is it then?
    : Could anybody give me a hint, please,
    : what that condition could be?
    :
    : Thank you!
    : Jabo
    :
    : Jabo
    :
    Basically, document.all is returning a true or false condition, to see if the document was loaded. if (something) can take any condition as long as it is true or false.



Sign In or Register to comment.