Written by Chris Walker
There are the basic operators that include
- Addition (+) (Also works on strings!)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%) divides one number by another until decimals are needed. Then it just returns the remainder.
Some of these can be used to modify a variable. That means it changes the value of the variable via that operator.
- Increment (++) increase by one
- Decrement (–) decreases by one
- “+=” Adds a number and makes that the new value. (Also works on strings!)
- “-=” Subtracts an amount from a variable
- “*=” multiplies a variable by a number
- “/=” divides it by a number
- “%=” Finds the modulus and assigns the variable that value.
There are also a few methods available to numbers
- toExponential() converts the number to an exponent. If a number is included in parentheses, the result has that many places past the decimal point.
- toFixed() Specifies number of digits allowed after the decimal. Good for forcing dollar amounts to show cents.
- toPrecision() Specifies the total number of digits to be shown. May force number to be an exponent.
- valueOf() Shows the value of the variable.
Go To An Older Location
Go To A Newer Location
Build A WordPress Theme From Scratch