Topic: About logical operator
This script
<html>
<body>
<script type="text/javascript">
var a =10;
var b = 20;
result = (a && b);
document.write(result);
</script>
</body>
</html>
will have the output: 20?
Why is that? && is a logical operator "AND". Why did that script resulted to 20? And when I assign text string such as dog or cat to variables a and b, it gives no result, but when I use true and false, the result always shows the value of the last variable used. for example:
<script type="text/javascript">
var a =true;
var b = false;
result = (a && b);
document.write(result);
</script>
Output will be : false
Same with logical operator "or" ( || ). Hope someone can help me understand this. I'm just a newbie with regards to Jscript.
