JavaScript
Data Types
Data Types
Strings
As strings must be written within
quotes, quotes inside
thestringmust be handled.
Thebackslash (\) escape
character turns special
characters intostringcharacters.
Data Types
Strings
Data Types
Strings
Data Types
The escape character (\) can
also be used to insert other
special characters into a string.
These special characters can
be added to a text string using
the backslash sign.
Data Types
Data Types
If you begin astringwith a
single quote, then you
should also end it with a
single quote. The same rule
applies to double quotes.
Otherwise, JavaScript will
Data Types
Booleans
In JavaScript Boolean, you can have
one of two values,
eithertrueorfalse.
These are useful when you need a data
type that can only have one of two
values, such as Yes/No, On/Off,
True/False.
Data Types
Booleans
Data Types
Booleans
The Boolean value of 0
(zero),null,undefined,
emptystringisfalse.
Everything with a "real"
value istrue.
Math Operators
Arithmetic Operators
Arithmetic operators
perform arithmetic
functions on numbers
(literals or variables).
Arithmetic Operators
Arithmetic Operators
In the example below, the
addition operator is used to
determine the sum of two
numbers.
Arithmetic Operators
You can add as many numbers
or variables together as you
want or need to.
Multiplication
The multiplication operator (*)
multiplies one number by the
other.
Division
The / operator is used to
perform division operations:
The Modulus
Modulus (%) operator returns
the division remainder (what is
left over).
Increment & Decrement
Increment ++
The increment operator increments
the numeric value of its operand by
one. If placed before the operand,
it returns the incremented value. If
placed after the operand, it returns
the original value and then
increments the operand.
Increment & Decrement
Decrement - The decrement operator
decrements the numeric value of its
operand by one. If placed before the
operand, it returns the decremented
value. If placed after the operand, it
returns the original value and then
decrements the operand.
Increment & Decrement
Increment & Decrement
As in school mathematics,
you can change the order
of the arithmetic operations
by using parentheses.
Example:varx = (100 +
50) * 3;
Homework
Prepare for a quiz about
JavaScript (starting from
First topic-First handouts)