Things You Need To Know For Interview Preparation

Sourav Sarkar Emon
4 min readNov 5, 2020

Our first and last mission as a web developer is to get a job and settle. To get a job as a web developer. To get the job you need to make a impression in interview. Some things if we know about this then we can make a great impression in interview.

In this article I am gonna talk about some things that gonna make your interview preparation rocks.

Common JavaScript Interview Questions

Some common tricky javascript things if you know all about this then I am sure you gonna rocks the interview section.

Truthy or Falsey Values

Two type of value has an inherent boolean value.

We will get always falsey from these values:

  1. “ ”, ‘ ’ (empty string)
  2. false
  3. null
  4. undefined
  5. NaN
  6. 0

Everything Is Truthy from these values:

  1. {} (object)
  2. [] (array)
  3. function() {}
  4. ‘false’

Null vs Undefined

Null and Undefined is not the same. They are fully difference one from another. But they have also some similarity.

You will get always undefined from these object:

* let name;                //(without define the variable)* function add(num1, num2) {
num1 + num2
} // without return the funciton
* function add(num1, num2) {
return num1 + num2;
}
console.log(add(20)); // If you don't pass the variable
*const object = {name: 'hulk', color: 'green'} // console.log(object.superpower) if you access an non property * const some = undefined // undefined is a reserved word

There are two features in null. You will get always null from:

let name = null;     // null must be assigned.
console.log(name) // null is an empty or non-existent value.

Double Equal(==) vs Triple Equal(===)

In javascript double equal and triple equal has its own meaning.

  1. Double Equal(==)

Double equal is used for type coercion. If we used double equal for checking or comparison something it wouldn’t check for data type. It will only check for only common values.

123 == '123'  //returns true
123 == 123 //returns true

2. Triple Equal(===)

Triple equal is used for value with data type coercion. Triple equal will check for common value with its data types.

123 === '123'  //returns false
123 === 123 //returns true

Function And Blocked Scope

We can declare variables in three way. var, let and const. Before es6 var was the common way to declare variable. But after es6 var a new rule estimated that declare variable with let and const is the best way.

//global scope
function examp1(){
//function scope
if(){
//blocked scope
}
}

1. Function Scope

Var can be re-assigned and updated after assigned. The ‘var’ variable is also function scope. The ‘var’ can be only available inside the function if they once created inside. If they are not created inside then they are called global scope.

function setName(){
var name = 'spiderman';
console.log(name);
}
console.log(name); //name is not defined

2. Blocked Scope

Let and const are blocked scope. They are only available in curly braces. We can’t access these values from out of the curly braces.

function setName(){
var name;
if(name){
let firstName = 'iron'; //blocked scope
const lastName = 'man'; //blocked scope
}

Some Common JavaScript Coding Problem

If you know some simple javascript coding problem then it will make your interview like as easy as pie. Here are some coding problem for you:

1. Find the largest element of array

const numbers = [21, 58, 45, 91, 18, 33, 40]
let max = numbers[0]
for(let i=0; i<numbers.length; i++){
let element = numbers[i];
if(element > max) {
max = element;
}
}
// get the largest element of array

2. Sum of all numbers in an array

const numbers = [21, 58, 45, 91, 18, 33, 40]
let sum = 0
for(let i=0; i<numbers.length; i++){
let element = numbers[i];
sum = sum + element;
}
// get sum of all numbers in an array

3. Remove duplicate item from an array

const roll = [21, 58, 45, 21, 12, 43, 45, 54]
let uniqueRoll = [];
for(let i=0; i<roll.length; i++;){
let element = roll[i];
let index = uniqueRoll.indexOf(element);
if(index == -1){
uniqueRoll.push(element);
}
}
//Remove duplicate item from an array

4. Count the number of words in a string

const message = 'quick brown fox jumps over the lazy dog';
let count = 0;
for(let i=0; i<message.length; i++;){
let letter = message[i]
if(letter = " "){
count++;
}
}
// Get number of words in a string

5. Reverse a String

function reverseString(str){
let reverse = '';
for(let i=0; i<str.length; i++;){
let char = str[i];
reverse = char + reverse;
}
return reverse;
}

Don’t ever think you can’t do something and be the best.

If you know these js coding question answer and these coding problem then all js interview will be as easy as pie for you.I hope this short article has influenced you in a positive way.

--

--