[go: up one dir, main page]

0% found this document useful (0 votes)
12 views25 pages

Javascript

JavaScript is an interpreted, client-side scripting language that allows dynamic modification of HTML pages and user input validation. It supports various frameworks and libraries, such as Angular and React, and has specific rules for variable declaration and data types. The language includes conditional statements like if-else and switch for decision-making in code execution.

Uploaded by

nidkyyou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views25 pages

Javascript

JavaScript is an interpreted, client-side scripting language that allows dynamic modification of HTML pages and user input validation. It supports various frameworks and libraries, such as Angular and React, and has specific rules for variable declaration and data types. The language includes conditional statements like if-else and switch for decision-making in code execution.

Uploaded by

nidkyyou
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

What is JavaScript

JavaScript is an interpreted, client side, event based,


object-oriented scripting language.
Invented in 1995 at Netscape corporation.
It is a case sensitive language.
What can JavaScript do?

 JavaScript can dynamically modify an html page.


 JavaScript can validate user input.
 It is full featured programming language.
 JavaScript user interaction does not require any
communication with the server
 JavaScript is dynamically typed language.
Uniqueness

 Support by all major browser and enabled by


default.
 Complex things done simply.
 Full integration with HTML/CSS.
Frameworks and libraries

1. Angular
2. React
3. Ext.js
4. node,.js
5. JQuery
6. Vue.js
7. Ember.js
8. Polymer
9. Backbone.js
10. Aurelia
Variables

 Variables are Containers for Storing Data


 JavaScript Variables can be declared in 4 ways:
 Automatically
i. Using var
ii. Using let
iii. Using const
Rule for declaring variables

 The general rules for constructing names for variables


(unique identifiers) are:
 Names can contain letters, digits, underscores, and dollar
signs.
 Names must begin with a letter.
 Names can also begin with $ and _ (but we will not use it
in this tutorial).
 Names are case sensitive (y and Y are different variables).
 Reserved words (like JavaScript keywords) cannot be used
as names.
JavaScript Data Types

 Primitive data types.


1. String
Number
Bigint
Boolean
Undefined
Null
Symbol
Non-primitive data type

 Built-in object types can be:


 objects, arrays, dates, maps, sets, intarrays, floatarrays, promises,
and more.
Let , const and var

 Var: variable can be re-declared and updated. A global scope variable


 Let: variable cannot be re-declared but can be updated. A block
scope variable.
 Const: variable cannot be re-declared and updated. A block scope
variable
JavaScript operators

 There are different types of JavaScript operators:


 Arithmetic Operators
 Assignment Operators
 Comparison Operators
 String Operators
 Logical Operators
 Bitwise Operators
 Ternary Operators
 Type Operators
Arithmetic operator
JavaScript Assignment Operators

 Assignment operators assign values to


JavaScript variables.
Comparison Operators
 Comparison operators are used in logical
statements to determine equality or difference
between variables or values.
JavaScript if, else, and else if

 Conditional statements are used to perform


different actions based on different conditions.
Conditional Statements
 Very often when you write code, you want to
perform different actions for different decisions.
 You can use conditional statements in your code to
do this.
 In JavaScript we have the following conditional
statements:
 Use If to specify a block of code to be executed, if a
specified condition is true
 Use Else to specify a block of code to be executed, if
the same condition is false
 Use Else if to specify a new condition to test, if the
first condition is false.
 Use Switch to specify many alternative blocks of
code to be executed
If condition

 if (condition) {
// block of code to be executed if the condition is
true
}
The else Statement

 if (condition) {
// block of code to be executed if the condition is
true
} else {
// block of code to be executed if the condition is
false
}
The else if Statement

 if (condition1) {
// block of code to be executed if condition1 is
true
} else if (condition2) {
// block of code to be executed if the condition1 is
false and condition2 is true
} else {
// block of code to be executed if the condition1 is
false and condition2 is false
}
JavaScript Switch Stateme
nt
 The switch statement is used to perform different actions based on
different conditions.
 Use the switch statement to select one of many code blocks to be
executed.
Syntax
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
This is how it works:
 The switch expression is evaluated once.
 The value of the expression is compared with the
values of each case.
 If there is a match, the associated block of code is
executed.
 If there is no match, the default code block is
executed.
Example

 Switch (expression){
 Case condition 1: statement(s)

break;
 Case condition 2: statement(s)

break;
 Case condition 3: statement(s)

break;
default statement(s)
}
Key difference between if-else and
switch statements
The Nested if Statement

 You can have IF a statements inside IF statements, this is called a


nested if.
 Syntax
 if condition1 {
// code to be executed if condition1 is true(optional)
if condition2 {
// code to be executed if both condition1 and condition2 are true
}
}

You might also like