Complete A Z Javascript Notes 1682741974
Complete A Z Javascript Notes 1682741974
Most popular and widely used scripting language in the field of web development.
It is an object-oriented language which is lightweight and cross-platform.
JavaScript is not a compiled language, but it is a scripting language or interpreted
language.
Used for client-side scripting and server-side scripting. And is case sensitive
language.
Features of JavaScript:
JavaScript is very popular and the popularity of the JavaScript is increasing day-by-
day.
It is used in almost every field like web development, game development, mobile
apps development, etc.
It has a large number of support community with daily active users.
For the development you don’t need to setup extra environment or compiler for the
execution of the code.
Google
Facebook
Paypal
Netflix
Microsoft
Where JavaScript is used?
To run the javascript code in the browser just open you browser right click and select
inspect then select console and you can write your code in the browser.
Example:
ii. alert is basically used to show the alert box on the browser window.
alert(‘Alert box got Javascript Doctory Series’);
iii. prompt is used to get the value and store it to the variable. (we will learn about
variables in javascript soon).
prompt(‘Promptt box got Javascript Doctory Series’);
What is Variable?
Variables are just like a container which we use to store some values.
JavaScipt provides three types of keywords to declare varia bles.
let, var, const are used to declare variables in javascript.
In these day var is less used to declare variables.
Rules for creating variables:
Variable name must start with letters(a to z or A to Z), underscore(_), dollar sign ($).
Variables are case sensitive. So raju_webdve and Raju_Webdev are different.
After first letter of variable name we can use number (digits) in variable name. Like
let raju_webdev20;
Using variables:
let
let keyword is used to declare variable in javascript. The value of variable can be
changed which variable is created using let keyword.
Example:
var
var keyword is also used to declare variable in javascript. It has global because If you
initialize the value of the variable then it will change the value. And you cannot
declare the same name variable aging using var.
Example:
const
As the name suggest const the variable which is created using const cannot be
changed the value can be declare and initialize once.
Example:
In JavaScipt datatype define that which type of value can be stored in variables.
And we can also find that what it the type of the variable using typeof(variable_name)
In javascript there are mainly two types of data types. Premitive data types and
Reference(derived) data types.
Using Datatypes:
Premitive data types are those data types who are already define in the javscript
language. There is multiple type of primitive data types in javascript and these are:
Example:
Reference data types are those data types which are not predefine. And these data
types are also known as derived data types. And the reference or derived data types
in javascript are:
i).Object: It is used to store multiple collections of data in the pair or key value.
Example:
let myObject = {
name: 'raju_webdev',
website: 'geeks help',
role: 'frontend developer',
age: 20
}
console.log('Our object is: ' + myObject)
function myFunction(){
console.log('This is myFunction');
}
myFunction();
String
String methdos:
Length
This string methods is used to find the length of the given string
Example:
toLowerCase()
It is used to convert the string into lower case
Example:
toUpperCase()
It is used to convert the string into upperCase
Example:
let name = 'geeks Help';
console.log(name)
console.log('String into upper case is: '+ name.toUpperCase());
output:
geeks Help
String into lower case is: GEEKS HELP
charAt()
This method is used to get the character at the given index
Example:
includes()
It will return true if a string have given character or string otherwise it will return false
Example:
geeks help
concat()
It is used to concatenate two string.
Example:
endsWith()
It return true is string ends with given character either it will return false
Example:
output:
replace()
It is used to replace the given string with another one.
Example:
raju webdev
split()
This method splits a string into an array of substrings.
Example:
slice()
This will print the string between given indexes.
Example:
raju W
indexOf()
It will return the index of given character from a string.
Example:
Type conversion
It is the process of converting one data type into another data type.
Converting number into string is a type conversion.
1.
3.
4.
5.
Type coercion
The type coercion is implicit whereas type conversion can be either implicit or
explicit.
let a = 2004;
let b = '2004';
if(a===b){
console.log('a is equal to b');
}
else{
console.log('a is not equal to b');
}
output:
a is not equal to b
Boolean
Using boolan:
1.
Symbols
1.
Operators
Types of operators:
Unary operators:
These operators are used on single variables.
Unary operators are used to increment and decrement the value of variable.
Some unary operators are: ++, --, ~!
Example:
Relational Operators:
Relational operators describe the relation between two variables.
These operators returns true or false.
Relational operators are: ==, <, <=, >, >=, !=
Example:
output:
Num is 20
Arithmetic Operators:
Arithmetic operators are used to perform arithmetic operations. Like addition,
subtraction, multiplication, division, etc.
Arithmetic operators are: +, -, *, /, %
Example:
Assignment Operators:
Assignment operators are sued to assign value to the variables.
Assign the value by performing different operations.
Assignment operators are: =, +=, -=, *=, /=, %=, etc.
Example:
Arrays
Using Array:
Syntax of an Array:
const array_name = [item1, item2, item3,….item_n];
Example-1:
Example-2:
length
It is used to get the length of an array
Example:
indexOf()
It is used to get the index of given character
Example:
isArray()
It is used to get that does an object is an array or not if object is array then return
true otherwise. False.
Example:
unshif ()
It is used to put the element at the first index of an array.
Example:
pop ()
It is used to remove the last index element from an array.
Example:
shift()
It is used to remove the first index element from an array.
Example:
reverse()
It will reverse the given array.
Example:
const myArray = [20, 4, 15, 'Raju'];
console.log(myArray.reverse());
output:
[ 'Raju', 15, 4, 20 ]
concat()
It is used to concatenate two arrays.
Example:
Object
Object Declaration:
Syntax:
let myObject = {
key1: value1,
key2: value2,
key3: value3
}
console.log(myObject);
Example-1(Printing Object):
let obj = {
name: 'Raju',
page: 'raju_webdev',
role: 'web developer'
}
console.log(obj);
output:
{ name: 'Raju', page: 'raju_webdev', role: 'web developer' }
let obj = {
name: 'Raju',
page: 'raju_webdev',
role: 'web developer'
}
for(let key in obj){
console.log(`${key}: ${obj[key]}`);
}
output:
name: Raju
page: raju_webdev
let obj = {
name: 'Raju',
page: 'raju_webdev',
role: 'web developer'
}
console.log(obj.name);
output:
Raju
let obj = {
name: 'Raju',
page: 'raju_webdev',
role: 'web developer'
}
console.log(obj['page']);
output:
raju_webdev
Conditional Statements
If statement: In if statement, if the given condition is true then it will execute the
code.
Syntax:
if(condition){
// code to be executed
}
Example:
If-else statement: In the In if-else statement if the given condition is true then it will
execute the code of if block otherwise the else block will be executed.
Syntax:
if(condition){
// if block code
}
else{
// else block code
}
Example:
let age = 6;
if(age>18){
console.log("You can go to the party");
}
else{
console.log('You are under 18 you cannot go to the party.');
}
output:
Nested If-else statement: In this if else statement there will be another if condition
inside the main if condition
Syntax:
if(condition1){
if(condition2){
//first if code to be executed
}
}
else{
//else code to be executed
}
Example:
output:
If-else ladder statement: In this statement, there is multiple if blocks and also
known as else if ladder.
Syntax:
if(condition1){
// condtion1 if code
}
else if(condition2){
// condtion2 if code
}
else if(condition3){
// condtion3 if code
}
else{
// else code to be executed
}
Example:
Loops
Loops are:
for loop: for loops are commonly used to run code until the given conditions false.
Syntax:
while loop: In while loop the code will be executed until the given condition not
become false.
Syntax:
while(condition){
// code to be executed
}
Example:
let num = 0;
while (num<10) {
console.log(num);
num++;
}
output:
do-while loop: This is similar to while loop but in this the code will be execute at
least once then it will execute according to the condition.
Syntax:
do(condition){
// code to be executed
}while(condition);
Example:
let num = 0;
do{
console.log(num);
num++;
}while(num<10)
output:
When to use:
Break and continue are used to jump the flow of execution from one place to
another.
Mostly used inside the control statements.
These are used to exit a program from one control statement when the certain
conditions meet.
Break: Break statement is used to exit the current block in a given program.
Example:
let num = 1;
do{
console.log(num);
if(num===4){
break;
}
num++;
}while(num<=10);
output:
Continue: Continue statement is used to skip the current iteration and continue the
next iteration.
Example:
The number is 0
The number is 1
The number is 2
The number is 3
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
Function
Functions are:
function function_name(){
//code to be executed
}
Example:
function helloWorld() {
console.log('Hello World to regular function');
}
helloWorld();
output:
Hello World to regular function
Arrow function: Arrow functions is a new feature introduced in ES6, it enable writing
concise functions in javascript.
Single parameter function does’t need paranthesis.
Syntax:
Function returns something: A function which returns some value and store it into
a variable.
One line function doesn’t need braces to return.
Example:
The DOM represents the whole HTML document and it is the structured
representation of HTML document.
With the help of DOM, we can interact with our web page.
Using DOM:
Syntax:
window.document;
Properties of DOM:
window.document
It is used to access complete document of any web page.
Example:
document.all
It will give the collection of all HTML tags in DOM.
Example:
document.all
It will give the body tag of our web page.
Example:
output:
Note: output will be in your console.
document.forms
It will give the collection of all forms available in our DOM.
Example:
let documentForms=document.forms;
console.log(documentForms);
output:
Note: output will be in your console.
document.URL
The URL property is used to get the full URL of the documents.
Example:
let documentURL=document.URL;
console.log(documentURL);
output:
Note: output will be in your console.
document.bgColor
This property is used to get the body color.
Example:
document.bgColor = 'red';
console.log(document.bgColor);
output:
red
document.title
This property is used to get the title of the document.
Example:
let documentTitle=document.title;
console.log(documentTitle);
output:
Note: output will be in your console.
window. alert
It is used to show an alert on the user window screen.
Example:
window.alert('Welcome to javascript Doctory Series');
output:
Note: output will be in the alert box on the browser.
document. location
It is used to get the location of the document.
Example:
output:
Note: output will be in your console.
Element Selector
Element selectors are used to select the HTML elements within a document using
javascript.
getElementById();
This element selector is used to select the element by given id.
Example:
let id = document.getElementById('myId');
console.log(id);
output:
Note: output will be in your console.
querySelector();
This element selector is used to select the element by given class or id. This element
selector returns first match.
Example:
output:
Note: output will be in your console.
parentNode ();
This selector is used to get the parent of the selected element.
Example:
let myPara = document.getElementById('childPara');
let parent = myPara.parentNode;
console.log(myPara);
console.log(parent);
output:
Note: output will be in your console.
Multi-Element Selectors:
querySelectorAll ();
This selector will return a list of the document’s elements that match the specified
group of selectors.
Example:
getElementByClassName ();
This element selector is used to select the collection of elements by their class name.
Example:
getElementByTagName ();
This element selector is used to get the collection of given tag name
Example:
Traversing DOM
The nodes in the DOM are referred to as parents, children and siblings, depending on
their relation to other nodes.
ParentNode:
The parent of any node is the node that is closer to the document in the DOM
hierarchy. The parentNode property is read-only
parentNode
This element selector is used to select the element by given id.
Example:
nextSibling
It will return the next node on the same tree level.
Example:
nextElementSibling
It will return the next sibling element of the same tree level.
Example:
Child Nodes:
Child Nodes property is used to return a Nodelist of child nodes. ChildNodes includes
text and comments.
childNodes
It taks text and comments of the DOM.
Example:
firstChild
It will give the first child node.
Example:
lastChild
It will give the last child node.
Example:
nodeName
It will return the name of the current node as a string.
Example:
children
Example:
firstElementChild
It will return the first child element of the selected element.
Example:
lastElementChild
Example:
These methods are used to modify the selected elements on the DOM using some
methods. Like creating some elements on DOM. And set or change the properties of
the selected elements on the DOM.
createElement();
This method is used to create element.
Example:
createTextNode ();
This method is used to create a text node for text.
Example:
appendChild();
This method is used to append any element with respect to the selected element.
Example:
className();
This property is used to set class on the selected element.
Example:
id();
This property is used to set id on the selected element.
Example:
replaceWith();
This method is used to replace a element with another element.
Example:
removeChild();
This method is used to remove sub-element from the parent element.
Example:
hasAttribute();
This method is used to know whether the selected element has or not the targeted
property. It will return true or false
Example:
true
setAttribute();
This method is used to set the attribute on the selected element.
Example:
removeAttribute();
This method is used to set the attribute on the selected element.
Example:
Event Listeners:
An event listener is a mechanism in javascript that tells that what event is occurred.
Event listeners tell that what event has been occurred by the user on the DOM.
In our JavaScript Doctory Series we will used event listeners by using
addEventListner() methd.
Most common used Event Listeners are:
onClick
dblclick
mouseover
mousedown
mouseup
submit
click
This event listener used when a user click on an element.
Example:
submitBtn.addEventListener('click', function(){
})
output:
Submit Button Clicked.
dbclick
This event listener used when a user double click on an element.
Example:
submitBtn.addEventListener('dblclick', function(){
})
output:
Submit Button Double Clicked.
mouseover
This event is occur on the element when a mouse is used to move the cursor over the
element.
Example:
submitBtn.addEventListener('mouseover', function(){
})
output:
Submit Button Mouse Over
mouseup
This event listener used when a user moveup the mouse on the element.
Example:
submitBtn.addEventListener('mouseup', function(){
})
output:
Submit Button Mouse Up occurred.
submit
It is used when we want to submit the specified form.
Example:
submitForm.addEventListener('submit', function(e){
e.preventDefault();
})
output:
From submit button clicked.
Math Object:
PI
It is used to get the value of PI.
Example:
ceil
It is used to get the higher value.
Example:
output:
Higher value of 5.2 is: 6
floor
It is used to get the least value.
Example:
round
It returns a rounded number to the nearest interger.
Example:
abs
It is used to get the absolute value of the given number. It changes –ve to +ve.
Example:
sqrt
It is used to get the square root of the given number.
Example:
min
It is used to get the minimum value from the different values.
Example:
max
It is used to get the maximum value from the different values.
Example:
pow
It is used to get the power of the given number. And it take value and power.
Example:
E
Math.E is used to get the Euler’s number.
Example:
random
Random is the most used property of Math object. This property is used to get
random numbers.
Example:
Most important concept throw javascript learning these concepts are used to get the
current Date and Time and also used to perform many other operations on the
website.
Date and Time properties are:
new Date();
getDate();
getHours();
getMinutes();
getSeconds();
getTime();, etc.
new Date();
Used to get the current Time and Date.
Example:
getDate();
Used to get the date.
Example:
getHours ();
Used to get the current hour.
Example:
getMinutes();
Used to get the minutes.
Example:
getMonth();
Used to get the month.
Example:
getFullYear();
Used to get the full year.
Example:
setDate();
Used to set the date.
Example:
setFullYear();
Used to set the full year.
Example:
setHours();
Used to set the hours.
Example:
setMinutes();
Used to set the minutes.
Example:
setSeconds();
Used to set the seconds.
Example:
setMonth();
Used to set the month.
Example:
Local Storage:
In local storage, the data is store in the local memory of the web browser and local
storage data don’t have any expiry date. And the data is stored in key value pairs.
Local storage Methods:
setItem();
getItem();
removeItem();
clear();
setItem();
It is used to set the items in the browser storage.
Example:
getItem();
It is used to get the items from the browser storage.
Example:
localStorage.removeItem('myData');
clear();
used to clear the browser local storage.
Example:
localStorage.clear();
Session Storage:
In session storage, the data is stored for the particular session. And the data will be
lost when the web browser is closed.
Session Storage Methods:
setItem();
getItem();
removeItem();
clear();
setItem();
Example:
getItem();
Example:
removeItem();
Example:
sessionStorage.removeItem('myData');
clear();
Example:
sessionStorage.clear();
Class:
Object:
An object is an element (or instance) of a class. Objects have the behaviors of their
class.
Constructor:
Constructor is like a function which will be run after the creation of the object.
Example:
Inheritance:
Inheritance means get the some properties of already created class to create new
class. And extends keyword is used to create inheritance.
Super in Inheritance:
super keyword is used to get the constructor of the parent class or the super class.
Creating Inheritance:
Example:
output:
student {name: 'Jassi', class: 'BCA', roll: 4, section: 'A'}
student {name: 'Raj', class: 'BA', role: 'JavaScript', section: 'Web Developer'}
Synchronous
In synchronous programming the things will happen one at a time. More than one
thing cannot happen at one time.
In this statement of the code gets executed one by one
Example:
console.log('Raju Webdev');
console.log('Geeks Help');
Asynchronous
console.log('Raju Webdev');
setTimeout(() => {
}, 2000)
Output:
Raju Webdev
Hello Web Developers //it will print on console after two seconds
Synchronous Asynchronous
Operations task are performed one at a Operations will execute in the
time. background of another operation.
Another operation or code will executed Multiple operations can be executed at
after execution of previous code. one time.
It waits for each operation to complete. It never waits for each operation to
complete.
Callback:
The callbacks are used to make sure that a function is not going to execute before a
task is completed but will execute right after the task has completed.
We use callback functions are used to make the asynchronous programming.
Syntax:
// function
function function_name(firstArgs, callback){
// code to be executed
callback();
}
// callback function
function callback_function_name(){
//code to be executed
}
// passing function as an argument
function_name('firstArgs', callbackFunction);
Example:
// function
function greet(getName, callback){
console.log('Hi ', getName);
callback();
}
// callback function
function callMe(){
console.log('I am callback function');
}
// passing function as an argument
greet('Raju',callMe);
Output:
Hi Raju
I am callback function
Async / Await:
Async:
Syntax:
Example:
Await:
The await keyword is used inside the async function to wait for the asynchronous
operation.
await pauses the async function until the promise returns a result.
Syntax:
Fetch API:
Fetch API is an interface which allows us to make HTTP requests to servers from the
user web browsers.
Fetch is based on async and await programming nature.
fetch api uses two (.then) first to resolve the response from the server and second to
get the data from the response.
Syntax:
fetch(url).then((response)=>{
// response code
}).then((data)=>{
// data
})
readme.txt:
function readFile(){
fetch('readme.txt').then((response)=>{
return response.text();
}).then((data)=>{
console.log(data);
})
}
readFile();
Output:
Hello Developers this is our readme file of JavaScript Doctory Series
Error Handling:
Error handling is used to stop the generated error message and show a normal
message instead of showing error.
In javascript errors are handled at the runtime of the program.
In javascript try and catch block are used to handle errors. And one more block is
finally is also used to handle errors.
Syntax:
try{
// try block code
}
catch(error){
// catch block code
}
finally{
// finally block code
}
Try Catch:
In try catch block if there is any error then the catch block will show the message
instead of showing any error.
Example:
try{
console.log('Try Block executed');
name();
}
catch(error){
console.log('Catch block executed');
}
Output:
Try Block executed
Catch Block executed
In try catch and finally block the try and catch block will execute as we discuss in
previous example but the finally will show the message every time.
Example:
try{
console.log('Try Block executed');
name();
}
catch(error){
console.log('Catch block executed');
}
finally{
console.log('Finally block executed');
}
Output:
Try Block executed
Catch Block executed
Finally Block executed
Promises:
Promises is an object and promises are just like a promise which we do in our real-
life.
Promise performs different actions in which .then() used for promise is successfully
fulfilled or resolved and .catch() for reject or an error.
The function which is executed after the execution of another function that is finished.
Syntax:
web.then(function(){
console.log('Your promise is resolved.');
}).catch(function(){
console.log('Your promise is rejected.');
})
Output:
Your promise is resolved.
Cookies:
Cookies are some data & text files which stored on the webpage.
A web browser stores this information at the time of browsing.
Basically, it stores the information as a string in the form of a name-value pair.
document.cookie = "name=value";
Example:
document.cookie = "website=geekhelp";
Dates in Cookies:
You can also store the date in user’s web page. And we can also store multiple
information by sepration semicolon(;).
Multiple cookies:
Reading Cookies:
As we create the cookies insame way we can update the cookies by changing value.
Delete Cookie:
Destructuring:
It allows us to extract data from arrays, objects and maps or set them into new
distinct variable.
It allows us to extract multiple properties and items from an array at a time.
Destructuring used to break down the complex structure into small parts to easily
understand.
Array Destructuring
Object Destructuring
Syntax:
Example:
console.log(myArray);
})
Output:
['Orange', 'Apple', 'Banana']
Rest Operator
You can put all the remaining elements of any array in a new array using rest
operator(…)
Example:
Object Destructuring:
Example:
const myData = {
name: 'raju_webdev',
age: 19,
myClass: 'BCA',
};
Output:
raju_webdev BCA Geeks Help
OR
Example:
const myData = {
name: 'raju_webdev',
age: 19,
myClass: 'BCA',
};
Output:
raju_webdev {age: 19, myClass: 'BCA', website: 'Geeks Help', role: 'Frontend
Developer' }
Map:
In javascrit, map holds the key-value pairs. And it can be any type of key or value.
In map the key can be any type of data type.
The Map object can hold objects and primitive values as either key or value pairs.
Creating Map:
Example:
console.log(names);
Output:
Map(3) {'raju',=>2004, 'geekshelp'=>2021, 'webdev',2022 }
Map Methods:
new Map();
Creates a new Map object
Example:
console.log(names);
Output:
Map(3) {'raju',=>2004, 'geekshelp'=>2021, 'webdev',2022 }
set();
It will sets the value for a key in a Map.
Example:
const myMap = new Map();
let value1 = 'Age';
let value2 = 'Year';
myMap.set(value1, '20');
myMap.set(value2, '3rd Year');
console.log(myMap);
Output:
Map(2) {Age',=> '20', 'Year'=>'3rd Year'}
get();
It is used to get the value for a key in a Map.
Example:
myMap.set(value1, '20');
myMap.set(value2, '3rd Year');
console.log(myMap);
size
It will return the number of elements in Map.
Example:
myMap.set(value1, '20');
myMap.set(value2, '3rd Year');
values()
It is used to get the value from a Map.
Example:
myMap.set(value1, '20');
myMap.set(value2, '3rd Year');
Set:
Creating Set:
Set Methods:
new Set();
This will initialize an empty Set.
Example:
delete();
It will remove the specified element form the set.
Example:
values();
It will returns an object which contains all the values in a set.
Example:
Iterating a Set
Example:
Example:
Syntax:
Parameters of map:
Iterating Array:
myArray.map((value, index)=>{
console.log(value, 'at index', index);
})
Output:
raju_webdev at index 0
geeks help at index 1
instagram at index 2
web devp at index 3
for…in
Syntax:
const myData = {
name: 'Raju Webdev',
language: 'JavaScript',
class: 'BCA',
website: 'geekshelp.in'
}
for…of
for of loop allow us to iterate over the iterable object, arrays, sets, maps, etc.
Syntax:
Example:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Array Filter
Syntax:
Parameters of filter:
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
20
61
420
22
204
19
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
[ 4, 3, 1, 13, 15, 19 ]
Using filter with arrow function:
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
[ 4, 3, 1, 13, 15, 19 ]
Array Reduce:
Array reduce is used to perform some operation on array to get a single value.
array.reduce doesn’t execute the function for the empty array element.
It doesn’t change the original array but it give a single value output.
Syntax:
Parameters of reduce:
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
let sum = 0;
for(let i=0; i<values.length; i++){
sum += values[i];
};
console.log(sum);
Output:
782
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
console.log(valuesSum);
Output:
782
Using reduce with arrow function:
const values = [20, 4, 3, 61, 1, 13, 420, 22, 15, 204, 19];
console.log(valuesSum);
Output:
782
Hoisting:
Hoisting means moving the variable, function and class declaration to the top of
their scope.
Variables and class with declaration in javascript are hoisted.
Functions with function keyword are by default hoisted in javascript.
Syntax:
Variable Hoisting
Function Hoisting
Class Hoisting
Variable Hoisting:
It is the mechanism to move the declaration of the variable to the top of their
scope.
Variable created using var keyword will give undefined if we use it before
initialization.
Example:
console.log(myName);
var myName= 'raj';
Output:
Undefined
Variable defined with let and const are hoisted to the top of the block , but not
initialized.
Example:
console.log(myName);
let myName= 'raj';
Output:
ReferenceError: Cannot access ‘name’ before initialization
console.log(myName);
const myName= 'raj';
Output:
ReferenceError: Cannot access ‘name’ before initialization
Function Hoisting:
myName('raju_webdev');
function myName(name){
console.log('My Name is: ', name);
}
Output:
My Name is: raju_webdev
myName('raju_webdev');
Class Hoisting:
Output:
ReferenceError: Cannot access ‘name’ before initialization
setTimeout
This method is used to call a function after a number of given specified time in
milliseconds.
It is used to perform asynchronous programming.
It executes only once.
We can also set parameters in setTimeout()
Syntax:
function printOutput(){
setTimeout(function(givenName, givenRole){
let name = givenName;
let role = givenRole;
console.log('I am ', name, 'a', role);
console.log('Starting...');
printOutput();
Output:
Starting…
I am Raju a Frontend Developer
setInterval
This method is used to execute a function repeatedly within a given time interval.
It takes function and timeDelay as parameter and arguments as optional.
Syntax:
Example:
setInterval(function(givenName, givenRole){
Output:
I am Raju a Frontend Developer
I am Raju a Frontend Developer
I am Raju a Frontend Developer
……………………..
1) Digital Clock: This simple project you can create using Date.
2) Calculator: Most of the senior developers and mentor recomanded to create a
simple calculator app so you can create a calculator as a beginner level project.
3) Note App: You can create a note app as a beginner and can store the notes in
the local storage of the browser.
4) Slider: It is mostly created javascript project which you can create it will have the
previous and next buttion to slide the different images.
5) News Web: Create a news website using fetch api to show the real time news.
6) Form Validation: Form validation is mostly recommended project for beginners.
So as a beginner-level project you can create a project using javascript with the
specified validations.
7) Music Player: Create a music player which have same given music to play.
8) Speech-Recognition System: Create a speech recognition system like Jarvis.
9) Flappy Bird Game: It is the most common game most of the people had play this
game, So you can also create this game as your javascript project.
10) Real-Time Chat Application: You can also create a chat app using javascript
and NodeJs as a server.
11) Blog Web App: It will give the functionality to the use to signup or login. And
where user can like, comment, share, etc. the blogs.
12) E-Commerce: This project will be like Amazon and Flipcart.
13) College Library: Create a simple library using classes and create add book, issue
book, delete book, etc. functionality to the web app.
14) Hospital Management: A website which will give all the details from doctor to
patient. And and also will generate the reports.
Web Development Roadmap
This web develoment roadmap is a part of our JavaScript Doctory Series. And in this
web development roadmap our main focus is to make you a Full Stack Web
Developer using JavaScript as a main language.
Using javascript you can go in MERN, MEAN and MEVN stack. You can choose
according to your interest.
MERN: It is the most popular and demanding technology. And is for the beginners.
You can learn this by following the given steps:
HTML: HTML is used to create the structure of the web page.
CSS: CSS is used to implement the design to the web page.
JavaScript: JavaScript is used to add additional functionality to the web
page.
ReactJs: JavaScript library to build single page web applications.
NodeJs: Server environment.
Express: It the popular framework for NodeJs.
MongoDB: NoSQL database to deal with data.
MEAN: It is also the most popular and demanding technology. You can learn this
by following the given steps:
HTML: HTML is used to create the structure of the web page.
CSS: CSS is used to implement the design to the web page.
JavaScript: JavaScript is used to add additional functionality to the web
page.
Angular: It is very popular framework to build dynamic web applications.
NodeJs: Server environment.
Express: It the popular framework for NodeJs.
MongoDB: NoSQL database to deal with data.
Additional Skills: Now after leaning these technologies build some projects which
will help you to become job ready.
Additional Skills:
Git: It is a version control system which will help you to manage and keep
track of your code history. And it is a software.
GitHub: It is a hosting service and it is hosted on the web.
npm: npm stands for Node Package Manager. As it’s name suggest it is a
package manager for nodeJs.
Learning Resources: