Mock Interview Test.

Md.Saiful Islam
5 min readMay 17, 2020

--

Today’s mock interview questions and answers are given below.

  1. What is Inline Element

Answer:

Basically, an inline element does not cause a line break (start on a new line) and does not take up the full width of a page, only the space bounded by its opening and closing tag. It is usually used within other HTML elements.

Example of inline elements are:

· anchor <a> tag

· emphasis <em> tag

· image <img> tag

2. What is block-level element?

Answer:

A block-level element always starts on a new line and takes up the full width of a page, from left to right. A block-level element can take up one line or multiple lines and has a line break before and after the element.

Other examples of the block-level tag are:

  • Heading tags <h1> to <h6>
  • List (Ordered, Unordered, Description and List Item) tags <ol> , <ul> ,<dl> , <li>
  • Pre-formatted text tag <pre>
  • Blockquote tag <blockquote>

Example:

<div>this is <span> inline element</span></div><div>this is <p> block element</p></div>

Here first div show there result in a line but second div show there result in two line.

3. HTML Attribute vs DOM property

Answer:

When writing HTML source code,it can define attributes on HTML elements. Then, once the browser parses the code, a corresponding DOM node will be created. This node is an object, and therefore it has properties.

That means Attributes are defined by HTML. Properties are defined by the DOM.Attributes initialize DOM properties and then they are done. One more thing is — Property values can change; attribute values can’t.

For instance, this HTML element:

<input type=”text” value=”Name:”>

has 2 attributes (type and value).

4. Instance Member vs prototype member.

Answer:

A prototype property will be part of any object created from the so-called prototype, and this includes prototype chain.

A instance property will be part of the whole instance.

Let’s see an example to clarify this two things.

function Person(first, last, age) {    this.firstName = first;    this.lastName = last;    this.age = age;}Person.prototype.planet = "Earth";p1 = new Person("David", "Beckham", 39);p2 = new Person("Lionel", "Messi", 30);console.log(p1.planet) // EarthPerson.prototype.planet = "Mars"console.log(p1.planet) // Marsconsole.log(p1.planet === p2.planet) // true

5. Hoisting:

In JavaScript, Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.

Example:

// hoistingfunction codeHoist(){   a = 10;   let b = 50;}codeHoist();console.log(a); // 10console.log(b); // ReferenceError : b is not defined

Here a act as a global variable and hoisted to the top of the code and can be access from outside the function but b is local variable that’s why we are not access it from outside of the function.

6.Difference Typeof and Instance of?

Answer:

typeof is a unary operator that returns a string indicating the type of the unevaluated operand.

instanceof is a binary operator, accepting an object and a constructor. It returns a boolean indicating whether or not the object has the given constructor in its prototype chain.

Example:

const isString = (str) => {return typeof str === 'string' || str instanceof String}

7. What is Babel?

Answer:

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:

· Transform syntax

· Polyfill features that are missing in your target environment

· Source code transformations

Example:

// Babel Input: ES2015 arrow function[1, 2, 3].map((n) => n + 1);// Babel Output: ES5 equivalent[1, 2, 3].map(function(n) {    return n + 1;});

8. Advantages of MongoDB.

Answer:

The following are the few advantages of MongoDB NoSQL database over relational databases.

· MongoDB is a schema-less NoSQL database. We do not need to design the schema of the database when we are using MongoDB

· No complex joins are needed in MongoDB. There is no relationship among data in MongoDB

· MongoDB is easy to scale.

· It is very easy to set-up and install MongoDB.

· The document query language supported by MongoDB is very simple as compared to SQL queries.

· Because the MongoDB uses JSON format to store data, it is very easy to store arrays and objects.

· MongoDB is free to use. There is no cost for it. etc.

9. What is async/await?

Answer:

async/await is the new way of writing asynchronous or non-blocking code in JavaScript’s. It is built on top of Promises. It makes writing asynchronous code more readable and cleaner than Promises and Callbacks.

10. What does data structure mean? Say somethings on Stack and Queue data structure.

Answer:

A data structure is a specialized format for organizing, processing, retrieving and storing data. While there are several basic and advanced structure types, any data structure is designed to arrange data to suit a specific purpose so that it can be accessed and worked with in appropriate ways.

Stack:

. Stack follow a basic principle that is called LIPO (Last In First Out).That means we must delete the last element that pushed in stack. Let’s try to understand with the help of a real life example. When we browse a website, we may click link to go to another page. In that time web browser push an element in stack and if we click at back button, it removes last value and back us to previous page. It has three operational methods:

i) Push() — Add a value in stack

ii) Pop() — delete a value from stack

iii) Peek — Peek a value from stack

Queue:

It looks similar with stack but its follow FIFO (First In First Out) principle.

It also have three methods like as stack such as-

i) Enqueue() — Add a value in queue

ii) Dequeue() — delete a value from queue

iii) Peek — Peek a value from stack.

That’s all.Thank you😊.

--

--

No responses yet