Just like any other language, JavaScript uses the standard operators to perform any mathematical operation. Including the use of parenthesis rule also because they are mathematical rules you hardly find a programming language that run away from the conventional.

The following are the symbols and what are their respective roles in the JavaScript language:

– = Subtraction

* = Multiplication

/ = Division

% = Modulus

— = Decrement

+ + = Increment

<SCRIPT LANGUAGE=”JavaScript” type=”text/JavaScript”>
<! –
var sum = 5 +5;
var subtraction = 5-5;
var multiplication; = 5 * 5;
var division = 5/5;
var mod = 5%5;
document.write (sum);
document.write (“</br>”);
document.write (subtraction);
document.write (“</br>”);
document.write (multiplication);
document.write (“</br>”);
document.write (division);
document.write (“</br>”);
document.write (mod);
/ / ->
</ SCRIPT>

Mathematical operators can be used on variables of type integer and decimal, its use in other types of data end up generating error anyway are not compatible. The only exception I have is if the addition (+) where the operator is also used to concatenate strings, check out the example below:

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
<!–
var p1 = “text1″;
var p2 = “text2″;
var p3 = “text3″;
var vT = p1+p2+p3;
document.write (vT);
//–>
</SCRIPT>

An important item, as the plus sign is ambiguous is important to understand how it works. Often you need to concatenate two numbers in the same variable as String and it will be necessary to create a new one using string spacing, if this is not done the string will have the value of the sum of two values​​.

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
<!–
var num1 = 600;
var num2 = 28;
var v1 = num1+num2;
var v2 = num1+” “+num2;
document.write (v1);
document.write (“</br>”);
document.write (v2);
//–>
</SCRIPT>

In the example above we see the difference in the variable v1 is stored the value of the sum of the two numbers already stored in the variable v2 is a string containing two values​​, this item can often go unnoticed in programming, so it is important to be aware of these peculiarities. Want to test your code and still work with one of the most powerful tools for web development? Then download the free version already Scriptcase and start today to take advantage of all the benefits it can provide, download now and check.

a

## 5 reasons you can’t miss a Black Friday Scriptcase!

This November we bring you the biggest and most important discounts of the year! And do you know wh...

## Taking a look at Scriptcase version 9.7

After the big Scriptcase 9.7 presentation event, we have a new version of Scriptcase for download, ...