What is the difference between the following statements?
Statement 1:
JavaScript
x
2
1
var=2**2*3
2
Statement 2:
JavaScript
1
2
1
var2=2*2*3
2
I see no difference. This raises the following question.
Why is Statement 1 used if we can use Statement 2?
Advertisement
Answer
Try:
JavaScript
1
2
1
2**3*2
2
and
JavaScript
1
2
1
2*3*2
2
to see the difference.
**
is the operator for “power of”. In your particular operation, 2 to the power of 2 yields the same as 2 times 2.