DEV Community

Cover image for Top 10 JavaScript Interview Questions
Eftykhar Rahman
Eftykhar Rahman

Posted on • Updated on

Top 10 JavaScript Interview Questions

1 What are the data types?

Supported by JavaScript we have primitive data types like string, boolean, number, bigint, null and undefined which can represent integers with arbitrary precision and define null symbols we also have objects and functions

2 Is JavaScript a case-sensitive language?

Yes, JavaScript is a case-sensitive language. The keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters. 

3 How can you create an object?

JavaScript supports object concepts very well. You can create an object using the object literal as follows in order to create an object use curly braces.

4 How can you create an array in JavaScript?

In order to create an array use square brackets

5 What's the difference between anonymous and name functions in javascript?

We can define function declaration by using the function keyword and provide the name of the function. When we assign the function to a variable using function keyword and anonymous function where we do not provide the name of the function which makes it a little bit more difficult to call them from other places. The name function can be accessed before the declaration, but the anonymous function is not.

Below the name function code will work

hello();
function hello(){
console.log("Hello , will work");
}
Enter fullscreen mode Exit fullscreen mode

But below the anonymous function assigned to the variable will not work.

hello2();
var hello2 = function (){
console.log("Will not work");
}
Enter fullscreen mode Exit fullscreen mode

Reason: Hoisting

6 How does the type of operator work?

The type of operator is used to get the data type of its operand, the operand can be either a litterer or a data structure such as a variable, a function, or an object. An arrow operator that is placed before its single operand which can be of any type its value is a string indicating the type of the operand.

7 How to create a cookie using JavaScript?

The simplest way to create a cookie is to assign a string value to a document.cookie object. 

8 what's the difference between double and triple equal operators?

JavaScript has two visually similar yet very different ways to test equality. You can test equality with double or triple. Equal sign here is the difference. When using a triple equals in javascript we are testing for strict equality which means that both type and the value we are comparing have to be the same. When we use a double equal sign javascript will try to convert values to a like type and then compare the values for that reason usually you would rather use a triple equal sign.

9 What are the different kinds of browser storage?

If you open developer tools and navigate to the application tab you can see which storages are available in a chrome web browser. So except for the cookies which you already know you can use local storage or session storage and some browsers but not all of them support internal databases like index database and Web SQL.

10 what is the difference between null and undefined?

In a nutshell, undefined typical means that the variable has been declared but not defined where null is assigned value and it means nothing other than that. Both null and undefined are primitives and they are both falsely values.

So these were the top 10 interview questions that you might hear on your very first interview for a junior developer role.

Top comments (12)

Collapse
 
coderd profile image
Info Comment hidden by post author - thread only accessible via permalink

Nice article.

Few suggestions.

  • Question 1(Data Type), please add null and undefined in list of data type.
  • Question 5(Anonymous and Name function) , please add that name function can be accessed before declaration, but anonymous function are not.

Eg

Below name function code will work

hello();
function hello(){
console.log("Hello , will work");
}

But below anonymous function assigned to

variable will not work.

hello2();
var hello2 = function (){
console.log("Will not work");
}

Reason : Hoisting

Collapse
 
iamraufu profile image
Eftykhar Rahman

Thank you. Already Added

Collapse
 
cmuralisree profile image
Chittoji Murali Sree Krishna

Nice article, thank you for sharing 🙂

Collapse
 
iamraufu profile image
Eftykhar Rahman

You're welcome

Collapse
 
eissorcercode99 profile image
The EisSorcer

You rock for this. Thank You!

Collapse
 
iamraufu profile image
Eftykhar Rahman

You're welcome

Collapse
 
hima_khaitan profile image
Himanshu Khaitan

Useful!

Collapse
 
iamraufu profile image
Eftykhar Rahman

Thank You

Collapse
 
aagz profile image
Vladimir Chubar

Thank you.

Collapse
 
iamraufu profile image
Eftykhar Rahman

You're Welcome

Collapse
 
kaziminhaj profile image
KaziMinhaj

Great work. Take love

Collapse
 
iamraufu profile image
Eftykhar Rahman

Taken <3

Some comments have been hidden by the post's author - find out more