Here if
document.write(eval("(2 == 2)"));
it prints true
And
document.write(eval("(2 == 2)&(5<10)"));
it prints 1
Why not it always returns true or false.If conditions increases in string it gives 0 or 1.What is the way to get same type of result.
It prints
1because you used the bitwise and operator (&) instead of the logical and operator (&&).And because JavaScript is loosely typed it will treat the boolean value
trueas an int value of1, which you can check by invokingthe result will be