Mathematical operations in JavaScript



Hello Everyone in this post I am going to tell the basic rule Mathematical operations and Order of there Operations in JavaScript.

JavaScript supports basic mathematical operations such as subtraction,addition, multiplication and division.

These operation can be bone by using these symbols such as + for Addition, – for Subtraction, * for Multiplication and / for division.

Order of Operations

If we are performing several mathematical operation in a single line such as

2+3 *10 some of you might be thinking it will give result as 50 but this is not so in JavaScript multiplication goes first and the result will be 32

Java Script prefer Multiplication and division addition and subtraction in a simple words in mathematical operation division is preferred first after that multiplication followed by addition and at last subtraction.

So to make that operation work in a way you want you may use brackets as shown below

(2+3)*10 in his case result will be 50.

 

Stay tuned for the PHP Magento, WordPress, JavaScript and Magento2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento Development / PHP we can help you, just Click on the Link and send me your requirements.

Please Like the Post on Facebook or Google+.