What if(event) statement means in JavaScript?

Posted by j flo on Programmers See other posts from Programmers or by j flo
Published on 2014-06-13T04:57:50Z Indexed on 2014/06/13 15:40 UTC
Read the original article Hit count: 364

Filed under:
|

I'm rather new to JavaScript and programming in general so I am pretty much only used to seeing if statements that have some kind of comparison operator like, if (x < 10) or if(myBool).

I have seen an if statement checking against an event, but I don't understand what or why the event is being checked like that. What's the semantic meaning behind that check or comparison?

Here is the code in question:

if(event){
    event.preventDefault();
}

© Programmers or respective owner

Related posts about JavaScript

Related posts about if-statement