JavaScript/Operators/Exercises

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Topic: Operators

1 What is the result?

7    9    16    123   
  1 + 2 * 3
  1 + "2" * 3
  "1" + "2" * 3

2 What is the result?

0   1   1.5   4   12   13.5  
  1 + 2 ** 3 / 2 - 1
  9 / 2 * 3
  9 / (2 * 3)

3 What is the result?

0   1   2  
  x = 1; x++; alert(x);
  x = 1; alert(++x);
  x = 1; alert(x++);

4 What is the result?

true false
   1 == 01
   1 === 01
   "1" == 01
   "1" == "01"
   "1" == 0 + 1
   "1" == 0 + "1"
   "1" == 0 * 1
   "1" == 0 * "1"

5 What is the result?

true false
   true && false
   true && false || true
   true && false || !true
   !(true && false)