# JS 2 - Logical Operators • Tests two or more...

This preview shows pages 1–5. Sign up to view the full content.

CS 170  Javascript 2 Prof. Jim Appenzeller [email protected]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Arithmetic Operators Symbols of basic arithmetic operations: Division / Multiplication * Addition + Subtraction –  we can group operations with parentheses  Multiply and divide are performed before add and subtract JavaScript does not have an operator for exponents We call “Binary operators” those that operate on two values Eg   a+b Unary operators operate on one value eg increment ++   and decrement – (two minuses) can be prefix (--a) or postfix (a++)
Assignment  Operators = += -= *= /= < Less than <= Less than or equal to > Greater than >= Greater than or equal to == Equal to != NOT equal to Comparison Operators

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Logical Operators • Tests two or more relationships at the same time ▫ Teenagers are older than 12 and younger than 20 • Logical AND ▫ Symbol is && ▫ Result of (a && b) is true (a bool) if both a and b are true; else the result is false • Logical OR ▫ Symbol is || ▫ Result of (a || b ) is true if either a or b are true; else if BOTH are false, the result is false • Logical NOT ▫ Symbol is ! ▫ It is a unary operator; its result is the opposite logical value of the value it is applied to Comments in JS • Single Line comment: // your comment • Multi-line Comment: /* your comment */...
View Full Document

## This note was uploaded on 01/21/2012 for the course COMP SCIEN 198 taught by Professor Appen during the Spring '11 term at Rutgers.

### Page1 / 5

JS 2 - Logical Operators • Tests two or more...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online