JavaScript Most Important Interview Question

SHAHADAT HOSSEN
3 min readMay 8, 2021

What is javascript:

JavaScript is a dynamic computer programming language. It is most commonly used as part of lightweight and web pages, whose applications allow client-side scripts to interact with the user and create dynamic pages. It is an interpreted programming language with object-oriented capabilities.JavaScript client-side but in a special way, JavaScript can be run in the backend which is called a node. Node programming language or a system to run JavaScript is called JavaScript Runtime Environment.

key features of javascript: JavaScript is divided into two main features

  1. JavaScript is divided into two main features 2. Modern JavaScript Features

How javascript code work: The browser will run/execute these scripts. Unlike the client-side, the server-side, the code of the server-side languages ​​is executed/run through the webserver.

An edit context is created whenever a JavaScript program is run. At this stage, JavaScript allocates memory to all the variables and functions present in the program. Variables are stored with unchanged values ​​and the function is stored with all the code present in the specified function JavaScript has V8 engines to run. Justin compiles by exiting JavaScript. It is used sequentially. Who reads it and compiles it quickly if it optimizes something and gives results

What is DOM (Document Object Model): Document Object Model is a programming interface for HTML and XML documents. It represents the page so that programs can change the structure, style, and content of the document. DOM represents documents as nodes and objects. This way, programming languages ​​can link to the page. When a web page loads, the browser creates a document object model of the page. JavaScript changes HT elements and attributes. Can be modernized with CSS style.

The web page in the browser displays a document on the display. Presents the same document so that it can be manipulated. DOM is an object-oriented presentation of web pages, which can be modified into scripting languages ​​like JavaScript.

What is an API: API is an application programming interface through which one program can share data with another. application programming interface or API is a collection of a bunch of functions. It is an interface that a computer, library, or application provides to another application for the purpose of providing various services or for exchanging data. The post method is used to send data to the wave server and the gate is used to get the data from the server.

Calculate Factorial Number Using For Loop:

function factorialOf(integer) {
let factorial = 1;
for(let i = 1; i <= integer; i++) {
factorial *= i;
}
return factorial;
}
console.log(factorialOf(4));

Factorial In Recursive:

function factorialOf(num) {
if(num<0){
return -1
}
else if(num==1){
return 1;
}
else{
return(num*factorialOf(num-1));
}
}
var result = factorialOf(5)
console.log(result)
// output 120

Fibonacci

The Fibonacci sequence starting with zero and one. The series is created by adding the previous two numbers. For example, the early part of the sequence is 0, 1, 1, 2, 3, 5, 8.

function fibonacci(num){
var series =[0,1]
for(var i = 2; i <= num; i++){
series[i] = series[i-1]+series[i-2]
}
return series;
};
var result = fibonacci(10);
console.log(result)
//output [0,1,1,2,3,5,8,13,21,34,55]

Recursive Fibonacci:

function fibonacci(num){
if(num==0){
return 0;
}
else if(num==1){
return 1;
}
else{
return (fibonacci(num-1) + fibonacci(num-2))
}
};
var result = fibonacci(10);
console.log(result);
// output 55

--

--