What are Promises?

How does prototypal inheritance differ from classical inheritance?

 

 

callback and callback hell

 

Refactoring the functions to return promises and using async/await is usually the best option. Instead of supplying the functions with callbacks that cause deep nesting, they return a promise that can be awaited and will be resolved once the data has arrived, allowing the next line of code to be evaluated in a sync-like fashion.

What is a closure? Can you give a useful example of one?

  • A closure is a function defined inside another function and has access to its lexical scope even when it is executing outside its lexical scope. The closure has access to variables in three scopes:

  • Variables declared in its own scope
  • Variables declared in the scope of the parent function
  • Variables declared in the global scope

Can you describe how CSS specificity works?

Assuming the browser has already determined the set of rules for an element, each rule is assigned a matrix of values, which correspond to the following from highest to lowest specificity:

  • Inline rules (binary - 1 or 0)
  • Number of id selectors
  • Number of class, pseudo-class and attribute selectors
  • Number of tags and pseudo-element selectors

 

  • Specificity matrix: [inline, id, class/pseudo-class/attribute, tag/pseudo-element]

  • In cases of equal specificity, last rule is applied

 

What is HTML5 Web Storage? Explain localStorage and sessionStorage.

 

 

Contrast mutable and immutable values, and mutating vs non-mutating methods.

What is the only value not equal to itself in JavaScript?

 

NaN (Not-a-Number) is the only value not equal to itself when comparing with any of the comparison operators. NaN is often the result of meaningless math computations, so two NaN values make no sense to be considered equal.

 

Explain the difference between a static method and an instance method.

 

 

Static methods belong to a class and don't act on instances, while instance methods belong to the class prototype which is inherited by all instances of the class and acts on them.

Array.isArray // static method of Array
Array.prototype.push // instance method of Array

Done

JS INT-05

By Tarun Sharma

JS INT-05

React

  • 338