Skip to main content

what is statement and expression in javascript ?

Expression and Statement are very important component in javascript language.
Expression : Expression always create  value and can be set wherever a value is expected like function arguments or value assigning  in a variable.

val
2+val
fun("3","2")

Statement : In javascript statement perform action. Loop and if statement are example  of statement. Javascript wherever expect statement you can put expression but you can not put statement  where expression expect .

This is statement

 if(true){}

This is expression(function as expression)

function(){return true;}

So you can put expression in where statement is require

if(function(){return true;}){}

But you can not put statement in where expression is require

function(if(true){}){};

In next article i will describe why this two things are very important.

Leave a Reply

Your email address will not be published. Required fields are marked *