JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programming Tutorial | Edureka
The document provides an overview of JavaScript, highlighting its importance, fundamentals, and usage in web development. It covers key concepts such as data types, variables, functions, conditional statements, loops, and structures like arrays and objects. The document emphasizes the benefits of JavaScript, including ease of learning and interactivity in web applications.
What is JavaScript?
Webpages more interactive
Interpreted language
Interpreter
Runs on the client’s computer
JavaScript is a scripting language that allows you to implement complex things on web
pages.
Constants
Constants are fixedvalues that do not change during execution time.
Syntax:
1
2
const mybirthday;
mybirthday = ‘03.08.1996’ ;
Examples of constants
Reference Data Types- Objects
An object is a standalone entity, with properties and type.
Syntax:
1 let object1 = { };
Name
Age
Eye-colour
18.
Reference Data Types- Arrays
0 1 2 3 4
An array is a data structure that contains a list of elements. These elements are all of the
same data type, such as an integer or string.
Syntax:
1
2
let arr[ ];
let arr = new Array( ) ;
19.
Reference Data Types- Functions
A function is a block of organized, reusable code that is used to perform a single, related action.
Functions
Predefined
Functions
User Defined
Functions
Syntax:
1
2
3
function greetings( ) {
alert(‘ Hello everyone! ‘);
}
name of the function
enter parameters here
20.
Conditional Statements
Conditional statementis a set of rules performed if a certain condition is met. It is like an
‘If-Then’ statement. (IF a condition is met, THEN an action is performed)
If Statement
If code
End
Start
True
Condition
False
Exit
Syntax:
1
2
3
if(condition) {
statement;
}
21.
Conditional Statements
Conditional statementis a set of rules performed if a certain condition is met. It is like an
‘If-Then’ statement. (IF a condition is met, THEN an action is performed)
Else If Statement
If code
End
Start
True
Condition
False
Else if code
Syntax:
1
2
3
4
5
6
if(condition) {
statement a;
}
else (condition) {
statement b;
}
22.
Loops
Loops are usedto repeat a specific block until some end condition is met.
Loops
do whilewhilefor
Start
Conditional Code
Condition
False
True
End loop
23.
While Loop
While thecondition is true, the code within the loop is executed.
Start
Conditional Code
End
True
False
Condition
While loop
Syntax:
1
2
3
while(condition) {
loop code;
}
24.
Do While Loop
Thisloop will first execute the code, then check the condition and while
the condition holds true, execute repeatedly.
Start
Conditional Code
End
True
False
Condition
Do while loop
Syntax:
1
2
3
4
do {
loop code;
}
while(condition);
25.
For Loop
Repeatedly executesthe loop code while a given condition is TRUE. It
tests the condition before executing the loop body.
For loop
Start
Execute Statement (s)
End
Next item from
sequence
If no more itemsItem from
sequenceSyntax:
1
2
3
for(begin; condition; step) {
loop code;
}
26.
Switch Case
The switchstatement is used to perform
different actions based on different
conditions.
Syntax:
1
2
3
4
5
6
7
8
9
10
switch(expression) {
case 1 :
code block 1
break;
case 2 :
code block 2
break;
default :
code block 3
}
Start
Switch expression
End
Case 1
Case 2
Default
Code block 1
break;
Code block 2
break;
Default statement
False
False