Login 
Password
  
 


JavaScript Cert. Exam
Test your skills with our JavaScript certification exam and see how you stack up right now.

Homepage
Visit our homepage and find out more about what NCSA can do for you.

Introduction to JavaScript
Using JavaScript on your Webpage
A Simple JavaScript Application
Variables & Operators
Variables
Operators
Loops & Conditionals
Loops
Conditionals
Document Object Model
Nodes
Functions & Methods
Built-in Functions
User Defined Functions
Forms & Events
Forms
Events
Browsers
Cookies
Image Maps
Timing Events

Learn More About Us
Find out more about how our certifications can benefit you.

Course Descriptions
View a complete listing of certifications available through NCSA.

Employer Programs
Visit our employer programs page and discover the options available to connect you with our customers.

Certificate Database
Lookup a certification in our online database.

Affiliate Program
Make money by helping people get the computer training and certification they need. Sign-up Here!

Support Center
If you have questions or concerns feel free to visit our online support center.


 

Operators


The operators allow you to manage or change the value of variables. Just like other programming languages, JavaScript also supports different types of operators. The three basic types of operators are:

 

·        Assignment operators: The assignment operators allow you to assign values to variables. You can also use this operator to assign a calculated or replaced value to a variable

Example:

Operator

English

Example

Result

Explanation

=

 

Assignment

1) var2=5000

var1 =var2

 

 

 

2) Income = perks + salary

 

 

 

 

3) num = count++

var1= 5000

The statement var1 =var2 will assign the value of var2 to var1. So the value of var1 will also be 5000.

 

The statement Income = perks + salary use this operator to assign a calculated value to a variable

 

The statement num = count++ first assigns the value of count to num and then add 1 to count.

 

 

 

·        Arithmetic operators: The arithmetic operators allow you to perform arithmetic operations on the variables or numbers.

 

Example:

Operator

English

Example

Result

Explanation

+

Addition

c=a + b

a=2

b=2

c=4

The statement a + b will add the values of both “a” and “b”. So “c” contains 4.

-

Subtraction

c=a - b

a=6

b=2

c=4

The statement a - b will subtract the value of both “b” from “a”. So “c” contains 4.

*

Multiplication

c=a * b

a=6

b=2

c=12

The statement a * b will multiply the values of both “a” and “b”. So “c” contains 12.

/

Division

c=a / b

a=6

b=2

c=3

The statement a / b will divide the value of “a” with “b”. So “c” contains 3.

%

Modulus

c=a / b

a=53

b=10

c=3

The statement a % b will divide the value of “a” with “b” and shows the remainder. So “c” contains 3.

++

PreIncrement

a=5

b = ++a

a=6

b=6

The statement b = ++a first adds 1 to the value in "a" and then assigns that value to "b" so both variables now contain 6.

++

PostIncrement

a=5

b = a++

b=5

a=6

The statement b = a++ first assigns the value from "a" into "b" and then adds 1 to "a" so now "b" contains 5 and "a" contains 6.

––

PreDecrement

a=5

b = --a

a=4

b=4

The statement d = --a first subtracts one from "a" and then assigns the result to "d" so both variables now contain 4.

––

PostDecrement

a=5
b = a--;

b=5

a=4

The statement b = a-- first assigns the value from "a" into "b" and then adds 1 to "a" so now "b" contains 5 and "a" contains 4.

-

Negation

b=-a

a=20

b=-20

The statement b=-a will change the positive value of “a” to negative value in “b”. So “b” contains -20

 

·        Concatenation operator: The concatenation operator allows you to combine two string values.

Example:

Operator

English

Example

Result

Explanation

+

Concatenation

c=”my” + “car”

 

var = “6” + ”5”

Mycar

The statement my + car will concatenate the values “my” and “car”. So “c” will contain “mycar” and “var” will contain “65”

 

·        Comparison operators: The comparison operators allow you to compare two variables and find if they are equal, unequal, greater or less.

 

Example:

 Consider two values:

  var1 = 2

  var 2= 4

Operator

English

Example

 

Result

 

==

Equal To

var 1 == var 2

 

false

The statement var 1 == var 2 will compare the values of var1 and var2 for equality and displays false because var1 is 2 and var2 is 4

!=

Not Equal To

var 1 != var 2

true

The statement var 1 != var 2 will compare the values of var1 and var2 for inequality and displays true because var1 is 2 and var2 is 4

<

Less Than

var 1 < var 2

true

The statement will compare the values of var1 and var2 to check if var1 is less than var2 and displays true because var1 is 2 and var2 is 4

Greater Than

var 1 > var 2

false

The statement will compare the values of var1 and var2 to check if var1 is greater than var2 and displays false because var1 is 2 and var2 is 4

<=

Less Than or Equal To

var 1 <= var 2

true

The statement will compare the values of var1 and var2 to check if var1 is less than or equal to var2 and displays true because var1 is 2 and var2 is 4

>=

Greater Than or Equal To

var 1 >= var 2

false

The statement will compare the values of var1 and var2 to check if var1 is greater than or equal to var2 and displays false because var1 is 2 and var2 is 4

 


NCSA OnDemand Training Courses



Web-based Training Courses, including 7,500+ Videos & Articles, covering:

Microsoft Office
2003 | 2007
Microsoft Windows
Vista
Visio
2003 / 2007
OneNote
2003 / 2007
Project
2003 | 2007
Sharepoint
3.0
Access
2003 | 2007
Excel
2003 | 2007
Outlook
2003 | 2007
PowerPoint
2003 | 2007
Word
2003 | 2007
Office for Mac
2008
Excel for Mac
2008
Entourage for Mac
2008
PowerPoint for Mac
2008
Word for Mac
2008

Acrobat 8 Professional ADO.NET 2.0 ASP.NET 2.0 for Visual Basic 2005
C# 2005 Crystal Reports XI Exchange Server 2003
Flash 8 ActionScripting Flash 8 for Designer FrontPage 2003
Mind Manager 7 Pro + Project 2007 Mind Manager 7 Pro Fundamentals Office 2007 - What's New
Photoshop CS2 PHP Programming QuickBooks Pro 2006
SharePoint End User: Administrator SharePoint End User: Contributor SharePoint End User: Reader
Small Business Server 2003 SQL Server 2005 Visual Basic 2005
Windows Server 2003

Order NCSA OnDemand today and get access to over 7500 quality instuctor led videos and training courses covering today's most popular software programs and programming languages.

OnDemand Monthly - $25/month
No long term commitment.
Annual Member - $159/year
Save 50%off monthly price.
Premium - $249/year
Includes NCSA certifications


    

  
HOME    PRIVACY    EMPLOYERS    CERTIFICATION LIST    AFFILIATES    CONTACT US

© 2002-2010 National Computer Science Academy, All Rights Reserved.