Top 10 JavaScript Interview Questions

Sakhawat Hossain
3 min readMay 8, 2021

1.Count the number of words in a string.

Count a number of words in a given string is one of the most tricky for beginners. We com solve this problem in various ways. generally above the process, we count the number of spaces is given in the string. here the total number of spaces is the number of words.

var speech = "I am a good person. i don't snore at night";var count = 0;
for(var i = 0; i < speech.length; i++){
var char = speech[i];
if(char == " "){
const++
}
}
console.log(count);
// 9

2. Revers a string

This method is used to reverse the order of the elements in an array. One thing to note is, this method does mutate your original array.

function feverseString(str) {
var revers ="" ;
for (vat i = 0; i< str.length; i++){
var char + str[]i;
reverse = char + reverse;
}
}
var statement = "Hello Alien bhai brother."
var forAien = reverseString (statement);
console.log(forAlien);

3. What is JavaScript

JavaScript client-side browser is a programming language ​​but it can be used in a special way using the node backend with the node name.

4. How javascript code executes

V8 engine is use to run JavaScript. chrome is made by V8 engine. The function of V8 is to read JavaScript just in time and compile it immediately. If it needs to be optimized, it will be optimized and the results will be given.

5. Bubbling

Very simply, “bubbling” is the principle that an event in JavaScript travels upward, from the target element to its parent, and on to that element’s parent, and on and on, all the way up through the document object. This can lead to unintended consequences within your application, because, as the event ‘bubble’ rises, it will also run any handlers present on those ancestor elements.

6. Variable Declaration with let and const

In ES6 finally, we can declare variables with let and constants with const keywords. From name variables should be able to change the values and constants should not allow changing the values.

7. Arrow Function Syntax

An arrow function looks similar to a function expression it’s just shorter. Again we assign an anonymous function to a named variable. The syntax of the arrow function consists of zero or more parameters, an arrow => and then concludes with the function statements.

const name = (parameters) => {
statements
}

8.virtual DOM

Virtual DOM (VDOM) is a programming concept where the representation of a UI is stored in a standard, or “virtual” memory, and synced with a “real” DOM ​​by a library like ReactDOM. This process is called reunion. They look like a tree in the implementation of the “virtual dome” in response.

9. What is a Callback Function

At a fundamental level, functional programming specifies the use of functions as arguments. A callback function as a higher-order function is a function that is a function that is passed to another function as a parameter. The use of callback functions is also known as a callback pattern.

10. What is an API

API is an acronym for Application Programming Interface that software uses to access data, server software, or other applications and have been around for quite some time.

--

--