Skip to content

knrbokhari/interview_questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

interview-

Features

JavaScript

What is javascript?

Answer:

JavaScript is a single-threaded, scripting language that enables us to create dynamically updating content, control multimedia, animate images, and pretty much everything else. JavaScript is used both on the client and server sides, allowing us to make web pages interactive.

জাভাস্ক্রিপ্ট হল একটি single-threaded, scripting language যা আমাদেরকে dynamically content আপডেট করতে, মাল্টিমিডিয়া নিয়ন্ত্রণ করতে, ছবিগুলিকে অ্যানিমেট করতে এবং আরও অনেক কিছু করতে সক্ষম করে৷ জাভাস্ক্রিপ্ট ক্লায়েন্ট এবং সার্ভার উভয় দিকেই ব্যবহৃত হয়, যা আমাদের ওয়েব page গুলিকে ইন্টারেক্টিভ করতে দেয়।

How .js file executed on the browser ?

Answer:

Every Web browser comes with a JavaScript engine that provides a JavaScript runtime environment. For example, Google Chrome uses the V8 JavaScript engine. V8 is an open-source JavaScript engine developed for Google Chrome and Chromium web browsers. The browser’s built-in interpreter searches for <script> tag or .js file linked with an HTML file while loading a web page, and then interpretation and execution start.

What is a callback function?

Answer:

A callback is a function passed as an argument to another function.

function greeting(name) {
  alert(`Hello, ${name}`);
}

function processUserInput(callback) {
  const name = prompt("Please enter your name.");
  callback(name);
}

processUserInput(greeting);

What is a Closure in JavaScript? How does it work?

Answer:

A closure is a function having access to the parent scope, even after the parent function has closed. A closure gives us access to an outer function's scope from an inner function.

function makeFunc() {
  const name = 'Naeem';
  function displayName() {
    console.log(name);
  }
  return displayName;
}

const myFunc = makeFunc();
myFunc();

What is a recursive function?

Answer:

A recursive function solves a particular problem by calling a copy of itself and solving smaller subproblems of the original problems.

function countDownFrom(number) {
	for (let i = number; i > 0; i--) {
		console.log(i);
	}	
}

countDownFrom(5)

Difference between undefined and null?

Answer:

undefined is a type, whereas null is an object. undefined means a variable is declared, but no value has been assigned a value. null in JavaScript is an assignment value. You can assign it to a variable.

What are the different data types in JavaScript?

Answer:

Data types in JavaScript define the type of data that a variable can store. JavaScript includes primitive and non-primitive data types. The primitive data types in JavaScript include string, number, boolean, undefined, null, and symbol. The non-primitive data type includes the object. A variable of primitive data type can contain only a single value.

What is DOM?

Answer:

DOM stands for Document Object Model. It is a programming interface that allows us to create, change, or remove elements from the document.

Explain hoisting in JavaScript.

Answer:

In JavaScript, hoisting occurs during the creation phase of the execution context that moves the variable and function declarations to the top of the script.

Power

Difference between undefined and null?

Answer:

undefined is a type, whereas null is an object. undefined means a variable is declared, but no value has been assigned a value. null in JavaScript is an assignment value. You can assign it to a variable.

What are the differences between “==” and “===”?

Answer:

== in JavaScript is used for comparing two variables, but it ignores the data type of the variable. === is used for comparing two variables, but this operator also checks the datatype and compares two values.

What is an event bubbling in JavaScript?

Answer:

Event bubbling is a way of event propagation in the HTML DOM API, when an event occurs in an element inside another element, and both elements have registered a handle for that event. With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements. The execution starts from that event and goes to its parent element. Then the execution passes to its parent element and so on till the body element.

What are the ways to define a variable in JavaScript?

Answer:

  • Var – The JavaScript variables statement is used to declare a variable and, optionally, we can initialize the value of that variable. Example: var a =10; Variable declarations are processed before the execution of the code.
  • Const – The idea of const functions is not allow them to modify the object on which they are called. When a function is declared as const, it can be called on any type of object.
  • Let – It is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it’s defined in.

What is the purpose of ‘This’ operator in JavaScript?

Answer:

The JavaScript this keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object.

What are the scopes of a variable in JavaScript?

Answer:

The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.

What is ECMAScript?

Answer:

ECMAScript is a scripting language based on JavaScript.

What is ES6?

Answer:

ECMAScript 2015 was the second major revision to JavaScript. ECMAScript 2015 is also known as ES6 and ECMAScript 6. ECMAScript provides the specification on how JavaScript programming language should work. ES6 comes with significant changes to the JavaScript language. It brought several new features like, let and const keyword, rest and spread operators, classes, modules, and many other enhancements to make JavaScript programming easier and more fun.

Why will you use default parameters?

Answer:

Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.

How does the Spread operator work?

Answer:

The spread operator is a new addition to the set of operators in JavaScript ES6. The spread syntax works within array literals, function calls, and initialized property objects to spread the values of iterable objects into separate items.

What difference between class and object?

Answer:

A class is a template for creating objects in a program whereas the object is an instance of a class. A class is a logical entity while the object is a physical entity. A class does not allocate memory space on the other hand object allocates memory space. You can declare a class only once but you can create more than one object using a class. Classes can’t be manipulated while objects can be manipulated.

ক্লাস (Class) : অবজেক্ট অরিয়েন্টেড প্রোগ্রমিং এ সবার আগে ক্লাস (class) সম্পর্কে ধারনা নিতে হবে।ক্লাস হচ্ছে অবজেক্টের জন্য টেমপ্লেট।অবজেক্ট তৈরী করার আগে একটা ক্লাস তৈরী করে নিতে হয় এবং এই ক্লাসটিকেই instantiate করলে এটা একটা অবজেক্ট হয়ে যায় (new শব্দ দিয়ে instantiate করতে হয়->নিচে বিস্তারিত আছে)।ক্লাস তৈরীর জন্য প্রথমেই class এই শব্দটি লিখে এরপর যেকোন নাম দিতে হয় আর এরপর দ্বিতীয় বন্ধনির (curly braces) ভিতর সব কোড লিখতে হয়। অবজেক্ট (Object) : অবজেক্ট হচ্ছে অবজেক্ট অরিয়েন্টেড প্রোগ্রামিং এর মুল মেশিন।একটা ক্লাস তৈরী করে তাকে আগে অবজেক্ট বানিয়ে নিতে হয় এরপর এই অবজেক্ট এর প্রোপার্টিজ এবং মেথডে একসেস নিয়ে কাজ করা হয়।ধরুন উপরে যে ক্লাসটি তৈরী করেছি সেটি যদি অবজেক্ট বানাতে চান তাহলে new শব্দটি দিয়ে নিচের মত করে কোড লিখতে হবে।

Explain Call by value vs call by reference.

Answer:

In the Call by Value method, there is no modification in the original value. In the Call by Reference method, there is a modification in the original value.

What is a Prototype chain?

Answer:

Each object has a private property that holds a link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. By definition, null has no prototype, and acts as the final link in this prototype chain.

What is a Higher-order Function?

Answer:

A higher-order function is a function that takes a function as an argument, or returns a function. A higher-order function is in contrast to first-order functions, which don’t take a function as an argument or return a function as output.

Difference between Array vs LinkedList.

Answer:

An array is a collection of elements of a similar data type. A LinkedList is an ordered collection of elements of the same type in which each element is connected to the next using pointers.

What is API?

Answer:

API is Application Programming Interface. API allows two applications to talk to each other.

React

What are reactjs?

Answer:

React is a free and open-source front-end JavaScript library, ReactJS is used primarily for building user interfaces, especially for one-page applications. React is a free and open-source front-end JavaScript library for building user interfaces based on UI components.

What is Virtual dom?

Answer:

The Virtual DOM is the lightweight version of the Real DOM that React retains in memory. Updating the virtual DOM is comparatively faster than updating the Real DOM. A virtual DOM object has the same properties as a real DOM object, but it lacks the real thing's power to directly change what's on the screen. Manipulating the DOM is slow. Manipulating the virtual DOM is much faster because nothing gets drawn onscreen.

How does React work?

Answer:

React creates a virtual DOM. When the state changes in a component it firstly runs a "diffing" algorithm, which identifies what has changed in the virtual DOM. The second step is reconciliation, which updates the DOM with diff results.

Tell us about React Component lifecycle.

Answer:

A React component’s lifecycle is broadly classified into four parts:

  • initialization
  • mounting
  • updating, and
  • unmounting.

Power

Initialization: This is the stage where the component is constructed with the given Props and default state. This is done in the constructor of a Component Class.

Mounting: Mounting is the stage of rendering the JSX returned by the render method itself.

Updating: Updating is the stage when the state of a component is updated and the application is repainted.

Unmounting: As the name suggests Unmounting is the final step of the component lifecycle where the component is removed from the page

click here for more information

Differences between props and state?

Answer:

Props are used to pass data from one component to another. The state is local data storage that is local to the component only and cannot be passed to other components. A state is an object that stores the values of properties belonging to a component that could change over a period of time.

What is the purpose of useState?

Answer:

useState is a Hook that allows us to have state variables in functional components. we pass the initial state to this function and it returns a variable with the current state value and another function to update this value. The useState Hook can be used to keep track of strings, numbers, booleans, arrays, objects, and any combination of these.

What is a context API? How does it work?

Answer:

The React Context API is a way for a React app to effectively produce global variables that can be passed around. This is the alternative to "prop drilling" or moving props from grandparent to child to parent, and so on. Context provides a way to pass data through the component tree without having to pass props down manually at every level.

What is JSX?

Answer:

JSX stands for JavaScript XML. JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. JSX converts HTML tags into react elements.

What is the purpose of a custom hook?

Answer:

The main reason to write a custom hook is for code reusability. For example, instead of writing the same code across multiple components that use the same common stateful logic you can put that code inside a custom hook and reuse it. We can decide what it takes as arguments, and what it should return. In other words, it’s just like a normal function. Its name should always start with use so that you can tell at a glance that the rules of Hooks apply to it.

What does useEffect do?

Answer:

By using this Hook, you tell React that your component needs to do something after render. React will remember the function you passed (we’ll refer to it as our “effect”), and call it later after performing the DOM updates. In this effect, we set the document title, but we could also perform data fetching or call some other imperative API.

Nodejs

What is Nodejs?

Answer:

NodeJS is a cross-platform and open-source Javascript runtime environment that allows the javascript to be run on the server side. Nodejs allows Javascript code to run outside of the browser. Nodejs comes with a lot of modules and is mostly used in web development.

What is the use of Node.JS?

Answer:

Node.JS is used primarily for non-blocking and event-driven servers, because of its single-threaded nature. It is used for traditional websites as well as back-end API services and was designed with real-time, push-based architectures in mind.

how nodejs program lifecycle works?

Answer:

In order to understand its lifecycle you must be familiar with the event loop. Event loops are something that makes your task very fast and also it perform multitasking. It allows Node.js to perform non-blocking I/O operations. When you run your node file using node app.js then the script starts executing. It will be parsed by the parser into machine language that simply means all the functions and variables get registered in a memory location. After parsing the code our program reaches the point where it will not exit and will run an infinite no. of times which is possible all because of the event loop. Once the event loop has started executing and it will run as long as event listeners are registered.

Node vs javascript?

Answer:

Node javascript
NodeJS is a Javascript runtime environment. Javascript is a programming language that is used for writing scripts on the website.
NodeJS help javascript to run outside of browsers. Javascript can only be run in the browsers.
node is used on the server side. Javascript is used on the client-side.

Nodejs single-threaded or multi-threaded?

Answer:

A Node.js application runs on a single thread and the event loop also runs on the same thread. we can say Node.js is single-threaded but the catch is that there are some libraries in Node.js that are not single-threaded.

Where and why should you not use NodeJS?

Answer:

NodeJS should NOT be used where computations are CPU intensive. Eg: Data Analytics Server, Image Processing Servers, Video Processing Servers, etc. NodeJS is meant for highly I/O-bound operations which does not require heavy CPU-intensive operation/tasks.

What do you understand by callback, in NodeJS?

Answer:

A callback is a function that is to be executed after another function has finished executing  or called after a task is finished. It is the asynchronous equivalent of a function. All APIs of Node are written in such a way that they support callbacks.

What is Callback Hell?

Answer:

The asynchronous function requires callbacks as a return parameter. When multiple asynchronous functions are chained together then a callback hell situation comes up.

What do you mean by Asynchronous API

Answer:

All APIs of Node.js library are asynchronous that is non-blocking. It essentially means a Node.js-based server never waits for an API to return data. The server moves to next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.

Express

What is expressjs?

Answer:

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

how express works?

Answer:

Express provides methods to specify what function is called for a particular HTTP verb ( GET, POST, SET, etc.) and URL pattern ("Route"), and methods to specify what template ("view") engine is used, where template files are located, and what template to use to render a response.

What is Middleware in Express.js

Answer:

Middleware is a function that is invoked by the Express routing layer before the final request handler.

What is the HTTP module?

Answer:

The HTTP module creates an HTTP server that listens to server ports and then gives back the response to the client.

MongoDB

What is MongoDB?

Answer:

MongoDB is a source-available cross-platform document-oriented database program that is classified as a NoSQL database program. It uses JSON-like documents with optional schemas.

What is the purpose of a database?

Answer:

A database is a collection of information that is organized so that it can easily be accessed, managed, and updated.

What is CRUD?

Answer:

CRUD is an acronym for Create, Read, Update, and Delete. CRUD operations are basic data manipulation for databases.

Get vs post?

Answer:

GET is used for viewing something, without changing it, while POST is used for changing something. For example, a search page should use GET to get data while a form that changes your password should use POST .

PUT and Patch

Answer:

PUT is a method of modifying resources where the client sends data that updates the entire resource. PATCH is a method of modifying resources where the client sends partial data that is to be updated without modifying the entire data.

Difference between MySQL and MongoDB?

Answer:

  • MySQL: It is a Relational Database Management System (RDBMS), which makes use of SQL as a standard language to handle its database. Like different relational database management systems, MySQL makes use of a table-like structure to stow data.

  • MongoDB: MongoDB is a NoSQL database that utilizes the JSON-like structure to stow data elements. To modify and access data in MongoDB, the programmer ought to make use of the MongoDB Query Language (MQL).

What is populate in MongoDB?

Answer:

In MongoDB, Population is the process of replacing the specified path in the document of one collection with the actual document from the other collection.

What is Aggregation in MongoDB?

Answer:

Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single-purpose aggregation methods and commands.

what is Mongoose?

Answer:

Mongoose is an Object Data Modeling library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB. No, I heard it but I never use it for my projects.