Blog About Me Posts By Tags Subscribe Elastic Search My Sessions Terraform

Pavan Kumar Aryasomayajulu


Eval with multiple mathematical expressions seperated by semi-colon

Hi, Came across an interesting thing today.

eval(‘25;(100/10);40;30+40’)
What will be the output of this javascript statement.

The output of above statement is 70. So point here is if we pass semi-colon separated mathematical expressions to eval function in javascript then it would return the value of the last evaluated expression . So in our case the answer would be 30+40 ie 70.

Isn’t it  really cool……..:)


Thanks, Pavan

#javascript