Home > Article > Web Front-end > How to write square in javascript
The ways to write JavaScript squares are: 1. "console.log(2*10**3)" method; 2. "console.log(2*Math.pow(10,3))" method; 3. "console.log(2e3)" method and so on.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to write square in javascript?
Three ways to calculate square numbers in JavaScript
console.log(2*10**3) console.log(2*Math.pow(10,3)) console.log(2e3) console.log(2*1e3) console.log(2*10e2) console.log(2*1000e0) console.log(2*100000e-2)
The calculation results are all equal to 2000.
[Recommended learning: javascript basic tutorial]
The above is the detailed content of How to write square in javascript. For more information, please follow other related articles on the PHP Chinese website!