10 Important Interview Questions for Junior JavaScript Developer

  1. Truthy or Falsy Value: If we declare a number type variable and set a value that will be truthy conditionally if it’s not a zero! Every word is truthy including white space other than empty strings. But an empty array would be a truthy value. When a variable is declared but no value is assigned to it then it would be undefined. That means if we don’t define any value of a variable, javascript will count it as falsy value. If we set the value of a variable as null that would also be a falsy value. Also if we set False or NaN as the value that would be also a falsy value.
  2. Null Vs Undefined: If we set a variable but forget to set it’s value then it would be undefined. If we write a function and add 2 parameters and do some operations inside it but forgot to return the value that will be also an undefined function. In another case, if we declare a function with 2 parameters but don’t set the value for both of the parameters then it will be an undefined function. If we declare an object and set some properties but when we console the object we look for a property that we didn’t set that will make the output undefined. If we set the value of a variable undefined that will give the output undefined too. So we can say that undefined is a reserved word and that’s also a falsy value. Null means empty, or not existence but it has to set as the value. So undefined means something that isn’t present in the variable and null means something that has been set as null.
  3. Double Equal (==) VS Triple Equal (===): Double equal doesn’t check the data type but Triple equal does. For example if we set two variables named A and B and set values as 2, ”2” respectively And we check conditionally if both values are equal by using double equal then it would be a truthy value. But if we check the same thing using Triple equal then it would be a falsy value. That means Triple equal detects the data type of the variable B which value is a string and It’s not the same as the variable A which value is a number. So we can say double equal checks only value of the variable but triple equal checks value and data type both. Double equal compares true as 1 and false as 0.
  4. Map: Map is the alternative and the smarter way of using for loop. Usually map is applied to an array. So we can say that map is one of the most important features of ES6.

5. Filter: Filter is used to filter the data to select specific data. That means when a data fulfills the condition then it will pass through the filter. So we can say that filter is used to get some specific data using conditions. If the condition doesn’t match the array then it will return an empty array.

6. Find: Find returns only an element other than array. Find works on just the next element of it’s condition. That means it will return the first element after it fulfills the condition. Find is almost same as filter but it won’t return an empty array like filter. It will return undefined if there is nothing about the next element after fulfilling the condition.

7. Scope: When a variable is declared inside a function so it’s area is confined in function. That means we can’t get an output outside the function. But if the variable is declared as a global variable that means we can call that variable from inside the function or outside. So we can say that if we declare a variable inside curly braces that means it can’t be accessed outside the braces, but if we declare the variable globally we can access that from anywhere. But in case of using VAR as variable declaration, it will be a global variable even if it’s inside the curly braces.

scope code
scope result

8. Slice: Slice is the cutter to slice the specific index amount of an array. We can set a starting index and ending index to slice an array. And it will slice from starting index to last index before the ending index. That means if we set num.slice(3, 7) then it will slice index number 3, 4, 5, 6. And after slicing the array it will create a new array which means the original array will remain the same as previous.

9. Splice: Splice has some different features than slice. Splice can remove the items from an array and can inject items in that position. For example if we set num.splice (3,7) then it’s starting index is 3 and it will remove the next 7 items from the originalarray. That means the second parameter of the splice is the number of items we want to remove. And if we want to inject any item then we can just add them after the second parameter.

10. Join: Join is to use join something to all the elements of an array. Join returns a string. So If we want to join all the numbers we can join them easily or if we want to add any word after each array element then we can do that too.

That’s all for today. Will discuss the next topic in another story. Happy Coding!!

Programmer || Web Developer || Learner || Practitioner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store