Chapter:4 Data types:
1. Numbers
2. Strings
Note: When adding a number and a string, JavaScript will treat the number as a string.
JavaScript evaluate expressions from left to right. Different sequences can produce different results.
Ex: var x=16+"Volvo";
Outpt: 16Volvo
Numbers: JavaScript has only one type of numbers. Numbers can be written with or without decimals.
Strings: Strings are written with quotes. You can use single or double quotes.
Code:
Output:
Chapter:5 Operators: Add two numbers and add two statements
1. Arithmetic Operators
2. Assignment Operators
3. String Operators
4. Comparison Operators
5. Logical Operators
Arithmetic Operators: + Addition
- Subtraction
* Multiplication
** Exponentiation
/ Division
% Modulus
++ Increment
-- Decrement
Assignment Operators: = x=y
+= x=x+y
-= x=x-y
*= x=x*y
/= x=x/y
%= x=x%y
String Operators: The + and += operators can also be used to add strings.
Comparision Operators: == Equal to
=== Equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal
<= less than or equal
? ternary operator
Logical Operators: && logical and
|| logical or
! logical not
Code:
Output:
1. Numbers
2. Strings
Note: When adding a number and a string, JavaScript will treat the number as a string.
JavaScript evaluate expressions from left to right. Different sequences can produce different results.
Ex: var x=16+"Volvo";
Outpt: 16Volvo
Numbers: JavaScript has only one type of numbers. Numbers can be written with or without decimals.
Strings: Strings are written with quotes. You can use single or double quotes.
Code:
Output:
Chapter:5 Operators: Add two numbers and add two statements
1. Arithmetic Operators
2. Assignment Operators
3. String Operators
4. Comparison Operators
5. Logical Operators
Arithmetic Operators: + Addition
- Subtraction
* Multiplication
** Exponentiation
/ Division
% Modulus
++ Increment
-- Decrement
Assignment Operators: = x=y
+= x=x+y
-= x=x-y
*= x=x*y
/= x=x/y
%= x=x%y
String Operators: The + and += operators can also be used to add strings.
Comparision Operators: == Equal to
=== Equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal
<= less than or equal
? ternary operator
Logical Operators: && logical and
|| logical or
! logical not
Code:
Output: