- Using the || operator (OR)
if (confirm('Do you agree, or...') || confirm('...do you wish to revert?')) { alert('As you wish...'); }
If you click OK for first confirm() you will not see the second confirm(). When you use the || operator all conditions are checked until one is true.
- Using the && operator (AND)
if (confirm('Do you agree, and...') && confirm('...do you really confirm to agree?')) { alert('As you wish...'); }
Even If you click OK for first confirm() you will still see second confirm(). When you use the && operator all conditions are checked and all must be true.
Thursday, October 8, 2009
If You Ever Wanted to Know How JavaScript Conditional Operators Executes
Labels:
JavaScript
A basic conditional operators && OR || execution demo in JavaScript:
| This post is: |
Subscribe to:
Post Comments (Atom)


2 comments:
Cool post
Prasad
This is lame
Post a Comment
Be relevant. Spammers will be banned.