javascript_interview_questions
javascript_interview_questions
HTML
CSS
JAVASCRIPT:
javascript is a programming languae that is used for converting static web page
into interactive and dynamica webpages
v8
spidermonke
javascript core
chakra
3) what are the variables ? what is differnce betwee var, let and const keyword?
variables are used to store data
console.log(count);
//ouptut:uncaught
//reference:error
//count is not defined
const can be assigned only once, and its value cannot be changed afterwards
const = > block level
//using const
const z = 10;
z = 20;
console.log(z);
//Boolena
let istrue=true;
//Undefined
let x;
console.log(x);
//Output undefined
//Null
let y=null;
console.log(y);
=======================================================================
Types of Data Types:
============================
Primitive:
Numbers
Strings
Booleans
Undefined
Null
Nonprimitive:
================
Objects
Array
Function
Date
RegExp
5)What are the operators and what are the types of operators in JS ?
operators are used to perform operations on operands
Types of Operators
Arithmetic Operators
let x=12; y=14;
console.log(x+y)
console.log(x-y)
console.log(x*y)
console.log(x/y)
console.log(x%y)
console.log(x*y)
Assignment Operators
let x=10;
x+=5;
x=x+5;
console.log(x);
Comparison operators
let x=5;
let y=3;
console.log(x>y);
console.log(x<y);
console.log(x>=y);
console.log(x<=y);
console.log(x==y);
console.log(x!==y);
Logical Operators
let x=true;
let y=false;
console.log(x&&y);
//Logical AND: False
console.log(x||y);
Logical OR: true
console.log(!x);
String Operators
String Operators:
=================
let a = 'Hello';
let b = ' world';
var c=(a+b);
//Concatenation;
//Output: Hello world;
2)Ternary operator
let y = 20;
let z = y > 10 ? "1" : "0"
console.log(z);
//Output 1;
3)Switch Statement
let a=5;
switch(a){
case 1:
console.log("1");
break;
case 5;
console.log("2");
break;
default:
console.log("3");
}
//output 2:
//Get elementByID
It is used to select a single element by id
const elementByID = document.getElementById("myDiv");
console.log(elelmentByID.innerHTML);
8) what is DOM? what is the differnce betweem HTML and the DOM ?
DOM Stands for Document Object Model represent the webpage as a tree like structure
that allows javascriptto dynamically access and manipulate the content and
structure of the webpage
DOM is a tree kiind of structure in the form Hirarcy in the browser memory
if we want to add, delete orupdate and html element via js the user wants to add
one more paragraph inside the body elelment with the help of js one more element
has created and can be converted into html
9)what is a loop and types of loop in js?
a loop is a programming way to run a piece of code repeatedly until a certain
condition is met
javascript loops
for
wwhile
do-while
for...of
for...in
10)what are functions in JS? what are the types of functions in JS?
A fuction is a reusable block of code that performs a specific task;
Types of Funcitons:
Named Functions;
Anonymous Functions;
Functions Expression;
Arrow Functions
IIFE
Callback Fucntions
HighOrder Functions