Javascript Backend Interview Questions

In JavaScript, the == operator is used for equality comparison. It compares two values and returns true if they are equal, and false otherwise. However, it performs type coercion, which means it converts the operands to the same type before making the comparison.

Javascript
console.log(5 == '5'); // true, because '5' is converted to a number before comparison
console.log(5 == 5);    // true, both values are of the same type and equal
console.log(5 == 6);    // false, the values are not equal

Output
true
true
false



In JavaScript, Function.prototype.bind() is a method that allows you to create a new function with a specified this value and optionally some initial arguments.

Syntax:

const newFunction = oldFunction.bind(thisArg, arg1, ag2, ..., argN)

Object.freeze():

  • Object.freeze() is a method provided by JavaScript that freezes an object, making it immutable. This means that after calling Object.freeze() on an object, you cannot add, delete, or modify any of its properties.
  • Even attempts to modify the properties of a frozen object will fail silently in non-strict mode and throw an error in strict mode.
  • Object.freeze() operates on the object itself, making the object and its properties immutable.

const:

  • const is a keyword in JavaScript used to declare constants. When you declare a variable using const, you cannot reassign it to a different value. However, this does not make the object itself immutable.
  • If the variable is an object, its properties can still be modified or reassigned, but you cannot assign a new object to the variable.
  • In other words, const ensures that the variable reference cannot change, but it does not ensure immutability of the object itself.

In summary, Object.freeze() is used to make an object and its properties immutable, while const is used to create constants whose references cannot be reassigned, but it does not ensure immutability of the object itself.

IIFEs, which stands for Immediately Invoked Function Expressions, are JavaScript functions that are executed immediately after they are defined. They are commonly used to create a new scope and encapsulate code, preventing variable declarations from polluting the global scope.

Syntax:

(function (){ 
// Function Logic Here. 
})();

.forEach():

  • The .forEach() method is used to iterate over an array and execute a provided function once for each array element.
  • It does not mutate the original array and does not return a new array.
  • The callback function passed to .forEach() can perform actions on each element of the array, but it does not produce a new array.

.map():

  • The .map() method is used to iterate over an array and transform each element using a provided function.
  • It returns a new array with the results of calling the provided function on each element of the original array.
  • The callback function passed to .map() should return a new value for each element, which will be included in the new array.

A cookie is an important tool as it allows you to store the user information as a name-value pair separated by a semi-colon in a string format. If we save a cookie in our browser then we can log in directly to the browser because it saves the user information.

  • Create cookies: We can apply various operations on cookie-like create, delete, read, add an expiry date to it so that users can never be logged in after a specific time. A cookie is created by the document.cookie keyword.
  • Read cookies: This function retrieves the cookie data stored in the browser. The cookie string is automatically encoded while sending it from the server to the browser.
  • Clear cookies: Cookies expire, the date and time are specified in the “expires” attribute. As a result, the browser automatically deletes the cookies when the date and time exceed the expiration date (and time).

JavaScript closure is a feature that allows inner functions to access the outer scope of a function. Closure helps in binding a function to its outer boundary and is created automatically whenever a function is created.

Javascript
function foo(outer_arg) {

    function inner(inner_arg) {
        return outer_arg + inner_arg;
    }
    return inner;
}
let get_func_inner = foo(5);

console.log(get_func_inner(4));
console.log(get_func_inner(3));

Output
9
8









Explanation:

The foo function returns an inner function that adds its argument to the outer function’s argument. It creates a closure, preserving the outer function’s state. Output: 9, 8.

Arrow function {()=>} is concise way of writing JavaScript functions in shorter way. Arrow functions were introduced in the ES6 version. They make our code more structured and readable. Mostly in development phase mostly arrow function is used.

Syntax:

const gfg = () => {
    console.log( "Hi Geek!" );
}
gfg() // output will be Hi Geek!


Exports:

  • Exports are used to expose functionality from a module to other parts of the program.
  • You can export variables, functions, classes, or any other JavaScript entity by using the export keyword.
  • There are different ways to export:
    • Default Export: export default myFunction;
    • Named Export: export const myVariable = 10;
    • Named Exports from Expressions: export { myFunction };
  • You can have multiple exports in a single module.

Imports:

  • Imports are used to bring functionality from other modules into the current module.
  • You can import exported entities using the import keyword.
  • You can import default exports like this: import myFunction from './module';
  • You can import named exports like this: import { myVariable } from './module';
  • You can also import all named exports using the * as syntax: import * as module from './module';

JavaScript operators operate the operands, these are symbols that are used to manipulate a certain value or operand. Operators are used to performing specific mathematical and logical computations on operands.

Backend Developer Interview Questions

Backend development involves working on the server side of web applications, where the logic, database interactions, and server management take place. It focuses on handling data, processing requests from clients, and generating appropriate responses.

In this Top Backend Development interview questions, We cover Interview questions from all important topics from basic to advanced such as JavaScript, Node.js, Express.js, SQL, MongoDB, Django, PHP, Java Spring, and API. No matter whether you are a fresher or an experienced professional we have got questions that will enhance your skills and help you shine in your backend development interview.

Similar Reads

Backend Developer Interview Questions

Here, we have organized 85+ backend developer interview questions and answer based on different technologies, including:...

Javascript Backend Interview Questions

1. Explain equality in JavaScript...

Nodejs Backend Developer Interview Questions

11. What is Node.js and how it works?...

Expressjs Backend Developer Interview Questions

21. How does Express.js handle middleware?...

SQL Backend Developer Interview Questions

31. What is the difference between LEFT JOIN with WHERE clause & LEFT JOIN?...

MongoDB Backend Developer Interview Questions

38. What is BSON in MongoDB?...

Django Backend Developer Interview Questions

48. Explain Django Architecture?...

PHP Backend Developer Interview Questions

58. How do you enable error reporting in PHP?...

Java Spring Backend Developer Interview Questions

68. What Are the Benefits of Using Spring?...

API Backend Developer Interview Questions

78. What is an API (Application Programming Interface)?...

Contact Us