0% found this document useful (0 votes)
230 views39 pages

Javascript

The document covers an introduction to JavaScript, including its definition, purpose, history, and characteristics. It explains how JavaScript enhances web interactivity and details various programming concepts such as variables, data types, operators, and decision-making statements. Additionally, it discusses looping statements and different types of functions, including named, anonymous, arrow, callback, and higher-order functions.
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)
230 views39 pages

Javascript

The document covers an introduction to JavaScript, including its definition, purpose, history, and characteristics. It explains how JavaScript enhances web interactivity and details various programming concepts such as variables, data types, operators, and decision-making statements. Additionally, it discusses looping statements and different types of functions, including named, anonymous, arrow, callback, and higher-order functions.
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/ 39

DAY-01

Topics Covered : –
1. What is Javascript?
2. Why we need Javascript?
3. History of Javascript
4. JS Engines of different browser
5. Characteristics of Javascript
6. Ways to add Javascript
7. Variables in Javascript
8. Datatypes in Javascript
9. Operators in Javascript
10.Decision-Making Statements in Javascript
WHAT IS JAVASCRIPT

 JavaScript is a high level programming language which is used to create interactive


web pages.

 It is the only language understood by browser.

 JavaScript is a scripting language.

 It is the language you can use at browser side as well as server side.

 It is the most commonly and popular language used right now.

 A lot of framework and libraries are based on Javascript. It can be used for both
frontend and backend.
Frontend – React.Js, Angular.Js, Next.Js
Backend – Node.Js, Express.Js
WHY WE USING THE JS?

 We use JavaScript (JS) because it makes web pages interactive.


 Without JS:
 A website is just static—it only shows text and images but doesn’t respond when
you click buttons or type something.
 With JS:
 You can create dynamic content (like pop-ups, forms, and animations).
 It lets users interact (click, scroll, type, play music, etc.).
 It works in the browser without needing extra software.
 Basically, JS makes websites alive instead of just looking like a book.
HISTORY OF JAVASCRIPT (JS)

 1995 – Brendan Eich created JavaScript in just 10 days


while working at Netscape.
HISTORY OF JAVASCRIPT (JS)
JS ENGINES OF DIFFERENT BROWSER
CHARACTERISTICS OF JAVASCRIPT

1.Client-Side Scripting Language


2.Dynamically Typed Language
3.Weakly Typed Language
4.Interpreted Language
5.Synchronous in Nature (Single-Threaded)
CHARACTERISTICS OF JAVASCRIPT

1. Client-Side Scripting Language: 2. Dynamically Typed Language:

•Runs inside the browser (Chrome). •No need to define variable types (number,
•No need for a server to process every action. string, etc.).
•Example: Clicking a button changes text •JS automatically detects the type at runtime.
instantly.

3. Weakly Typed Language: 4. Interpreted Language:

•Allows operations between different data types. •Executes line by line in the browser (no need to
•Can cause unexpected behavior. compile).
•Example: (String + Number = String), (String - •Easier to debug but slightly slower than compiled
Number = Number) languages.
CHARACTERISTICS OF JAVASCRIPT

5. Synchronous in Nature (Single-Threded):

•Executes one task at a time in order.


•Can cause delays if one task takes too long.
•Example:

•console.log("First");
•alert("Pause here...");
•console.log("Second"); // Runs only after alert is closed

 But JS also supports Asynchronous tasks (like setTimeout & fetch) to handle multiple
things smoothly!
WAYS TO RUN JAVASCRIPT CODE (ENVIRONMENT
SETUP)
WAYS TO ADD JAVASCRIPT TO A WEBPAGE
VARIABLES IN JAVASCRIPT

Q. What is a Variable in
JavaScript?
 A variable is like a container that
stores data.
 It holds values that can be used and
changed in a program.

Types of Variables in JavaScript:


1.var
2.let
3.const
HOW TO DECLARE THE VARIABLE
DATATYPES IN JAVASCRIPT
PRIMITIVE DATATYPES

1. Number: It is the values which may be integers or decimal. (Ex: 10, 5.5, 3,27, etc)

2. String: It is the combination of characters. And it is enclosed between Single-quotes (‘’),

Double-quotes (“”). (Ex: “Hello”, “123”, etc.)

3. Boolean: It represents true or false values. True means (one-1) and false means (Zero-0).

(Ex: true or false)

4. Null: Means nothing or empty value but not zero (0).

5. Undefined: A variable that exists but has no value assigned yet.


NON-PRIMITIVE DATATYPES

1. Object: A collection of data which is stored in the form of key-value pairs.

2. Array: A collection of data that stores multiple type of data.

3. Function: A reusable block of code designed to perform specific task.


OPERATORS IN JAVASCRIPT

 Operators are predefined symbols which is used to perform some specific tasks.
DECISION-STATEMENTS IN JS

 A decision-making statement in JavaScript helps the program decide what to do


based on conditions.
 It checks if something is true or false and then runs specific code.
IF-STATEMENT

 If-statement: It will runs when the condition is true only.


IF-ELSE STATEMENT

 If-else statement: It will runs different true or false. If condition is satisfied then it
will execute the if block or condition is false then it will execute the else block
respectively.
ELSE-IF LADDER STATEMENT

 Else-if ladder: It will checks the multiple conditions.


CONDITIONAL / TERNARY OPERATOR

 Ternary Operator: The ternary operator in JavaScript is a shorthand way of


writing an if-else statement.
 It is also called the conditional operator and uses the ? : syntax.

 If the condition is true -> statement-1 will be executed


 If the condition is false -> statement-2 will be executed
DAY-02
Topics Covered : – 3. Types of Functions
1. Looping Statements i. Named Function
i. For-loop ii. Anonymous Function
ii. While-loop iii. Arrow Function
iii. do-while loop iv. Callback Function
2. Functions in Javascript v. Higher-Order Function (HOF)
i. What is Function?
ii. How to declare functions
iii. How to call or invoke the function
iv. What are parameters and arguments in
functions
LOOPING STATEMENTS

 Looping Statements: A looping statement is a way to repeat a block of code


multiple times based on a condition.
 This helps in doing repetitive tasks.
FOR-LOOP

 For-Loop: A for loop is used when you know how many times you want the code to
run.
 It includes three parts:
1. Initialization
2. Condition
3. Increment/Decrement
WHILE-LOOP

 While-Loop: A while loop runs as long as a condition is true. If the condition is


false from the start, it won’t run.
DO-WHILE LOOP

 Do-While Loop: A do-while loop is similar to the while loop but it runs at least
once.
FUNCTIONS IN JAVASCRIPT

 Function: A function in javascript is block of code written to perform a specific or


particular task.
 It is executed when it is called or invoked.
 Functions help to avoid repetition of code and make it reusable.
FUNCTIONS IN JAVASCRIPT

 Function Call Statement: A function call statement is the part of the program
where function is called, meaning the function is executed.
 A function call is the action that triggers that block of code.
 To call a function, you simply use its function name and followed by parentheses. ()
FUNCTIONS IN JAVASCRIPT

 Parameters: A parameter is a variable defined in a function’s definition.


 Arguments: An argument is the actual value that is passed to a function when it is
called.
TYPES OF FUNCTIONS IN JAVASCRIPT
1. NAMED FUNCTION

 Named Function: A function that is defined with a name is called as Named


Function.
 It is also called as Function Declaration.
WHAT IS return KEYWORD IN FUNCTION?

 return Keyword: The return keyword is used to send a value from a function back
to the caller.
 NOTE: It should be the last statement inside the function after that function
execution will be stopped.
2. ANONYMOUS FUNCTION

 Anonymous Function: An anonymous function is a function that does not have a


name.

 Q. How to call or execute the Anonymous Function?


3. ARROW FUNCTION

 Arrow Function: Arrow functions are a shorter way of writing functions.


 It is especially useful for anonymous functions.
 It is also called as Fat Arrow Function which is introduced in the ES6 version in
the year of 2015.
return KEYWORD IN ARROW FUNCTION

 1. Implicit Return: If the function has a single statement, you can omit the
return and curly braces {} .
 2. Explicit Return: If there are multiple statements, you need to use explicitly and
you have to use curly braces {} mandatory.
4. CALLBACK FUNCTION

 Callback Function: A callback function is a function passed into another function


as an argument, is known as callback function.
5. HOF FUNCTION

 HOF Function: HOF stands for Higher-Order Function in Javascript.


 A higher-order function is a function which accept a callback function as arguments
that function we called as Higher-Order Function.

You might also like