Mastering the Web
Contents
Website Planning Tutorial
Website Design Tutorial
HTML Tutorial
HTML Tables Tutorial
CGI Tutorial
JavaScript Tutorial
Perl Tutorials
CSS Tutorial
Installing a Web Server
Security Tutorial
HTML Cookies Tutorial
Web Tracking Tutorial
Download Free Programs
F.A.Q.

  1. JavaScript Tutorial
  2. How to make pop-up windows
  3. JavaScript Object Reference (1)
  4. JavaScript Object Reference (2)
  5. JavaScript Object Reference (3)
  6. JavaScript Object Reference (4)
  7. JavaScript Object Reference (5)
  8. JavaScript Object Reference (6)
  9. JavaScript Functions and Operators

Download FWTLogstat1

Download FWTLogstat2

JavaScript Functions and Operators

Functions

escape(character)
Returns a string containing the ASCII encoding of character in the form %xx where xx is the numeric encoding of the character.
eval(expression)
Returns the result of evaluating expression where expression is an arithmetic expression.
isNaN(value)
Evaluates value to see if it is NaN. Returns a boolean value.
parseFloat(string)
Converts string to a floating point number and returns the value. It continues to convert until it hits a non-numeric character and then returns the result. If the first character cannot be converted to a number the function returns "NaN".
parseInt(string,base)
Converts string to an integer of base base and returns the value. It continues to convert until it hits a non-numeric character and then returns the result. If the first character cannot be converted to a number, the function returns "NaN".
unescape(string)
Returns a character based on the ASCII encoding contained in string. The ASCII encoding should take the form "%integer" or "hexadecimalValue".

Assignment Operators

Operator Description
= Assigns value of the right operand to the left operand.
+= Adds the left and right operands and assigns the result to the left operand.
-= Subtracts the right operand from the left operand and assigns the result to the left operand.
*= Multiplies the two operands and assigns the result to the left operand.
/= Divides the left operand by the right operand and assigns the value to the left operand.
%= Divides the left operand by the right operand and assigns the remainder to the left operand.

Arithmetic Operators

Operator Description
+ Adds the left and right operands.
- Subtracts the right operand from the left operand.
* Multiplies the two operands.
/ Divides the left operand by the right operand.
% Divides the left operand by the right operand and evaluates the remainder.
++ Increments the operand by one (can be used before or after the operand).
-- Decreases the operand by one (can be used before or after the operand).
- Changes the sign of the operand.

Bitwise Operators

Operator Description
AND (or &) Converts operands to integers with 32 bits, pairs the corresponding bits and returns one for each pair of ones. Returns zero for any other combination.
OR (or |) Converts operands to integers with 32 bits, pairs the corresponding bits and returns one for each pair where one of the two bits is one. Returns zero if both bits are zero.
XOR (or ^) Converts operands to integer with 32 bits, pairs the corresponding bits and returns one for each pair where only one bit is one. Returns zero for any other combination.
<< Converts the left operand to an integer with 32 bits and shifts bits to the left the number of bits indicated by the right operand; bits shifted off to the left are discarded and zeros are shifted in from the right.
>>> Converts the left operand to an integer with 32 bits and shifts bits to the right the number of bits indicated by the right operand; bits shifted off to the right are discarded and zeros are shifted in from the left.
>> Converts the left operand to an integer with 32 bits and shifts bits to the right the number of bits indicated by the right operand; bits shifted off to the right are discarded and copies of the leftmost bit are shifted in from the left.

Logical Operators

Operator Description
&& Logical "and"; returns true when both operands are true, otherwise it returns false.
|| Logical "or"; returns true if either operand is true. It only returns false when both operands are false.
! Logical "not"; returns true if the operand is false and false if the operand is true. This is a unary operator and precedes the operand.

Comparison Operators

Operator Description
== Returns true if the operands are equal.
!= Returns true if the operands are not equal.
> Returns true if the left operand is greater than the right operand.
< Returns true if the left operand is less than the right operand.
>= Returns true if the left operand is greater than or equal to the right operand.
<= Returns true if the left operand is less than or equal to the right operand.

Conditional Operators

Conditional expressions take the form:

    (condition) ? val1 : val2

If condition is true, the expression evaluates to val1, otherwise it evaluates to val2.

String Operators

The concatenation operator (+) is one of the two string operators. It evaluates to a string combining the left and right operands. The concatenation assignment operator (+=) is also available.

Operator Precedence

JavaScript applies the rules of operator precedence as follows (from lowest to highest precedence):

    comma (,)
    assignment operators (= += -= *= /= %=)
    conditional (? :)
    logical or (||)
    logical and (&&)
    bitwise or (|)
    bitwise xor (^)
    bitwise and (&)
    equality (== !=)
    relational (< <= > >=)
    shift (<< >> >>>)
    addition/subtraction (+ -)
    multiply/divide/modulus (* / %)
    negation/increment (! - ++ --)
    call, member (() [])

Previous | Contents | Next

| HOME | FEEDBACK | BOOKMARK |
Build your Website
© 1999-2008 Hector Castro -- All rights reserved

If your doubt is not answered in this site, please use the
contact form .
I'll answer as soon as posible.
I can help you using instant messaging. To schedule a meeting, please use the
meeting form.
You will find the late news about the free programs offered here on my blog
Free Webmaster Tools
You can get news about updates to my free programs through this
RSS feed.

www.great-web-info.com