To 10 JavaScript interview Question and solution

Sultan Mahmud
3 min readMay 8, 2021

--

1.This

If a method or function contains “this”, then “this” will represent the object from which the method or function will be called.

In a method, this refers to the owner object.

2.Encapsulation

Encapsulation does not hide data at all, it is just a security wrapper on the data. To set the data using the setter method and to get the data using the getter method

3. JavaScript Closures

Closure is a function with some remember values. A Closure gives you access to an outer function scope from an inner function.

4.prototype

A prototype is the property of any function in JavaScript that points to an object. The prototype works as an inheritance.

5.Call/Apply/Bind

We can use the method or function of one object in another object through call, apply and bind.

note: bind return a function but call and apply doesn’t return.

first image… applying method of an object. the second image.. use this method from another object.

6. Truthy and Falsy

A falsy value is something that evaluates to FALSE, for instance when checking a variable. There are only six falsy values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false of course.

example :

7. Null Vs Undefined

In JavaScript, undefined is a type, whereas null an object. It means a variable declared, but no value has been assigned a value. Whereas, null in JavaScript is an assignment value.

8. Double equal (==) vs Triple equal (===)

The double equal only check value is equal or not but the triple check value and data type is equal or not.

example:

9.Count the number of words in a string

solution:

10.Remove duplicate item from an array

solution:

11.Find Factorial on Recursive Method

solution:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sultan Mahmud
Sultan Mahmud

No responses yet

Write a response