0% found this document useful (0 votes)
6 views

JavaScript Interview Questions

Amswer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JavaScript Interview Questions

Amswer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Important

JavaScript Concepts

For Interviews
Part 5 Final

Kailash G
What do you mean by strict
mode in javascript and
characteristics of javascript
strict-mode?
In ECMAScript 5, a new feature called JavaScript Strict Mode allows
you to write code or a function in a "strict" operational environment.
When it comes to throwing errors, javascript is often 'not extremely
severe'. However, in "Strict mode," all errors, even silent faults, will
result in a throw. Debugging hence becomes more easier. Thus, the
chance of a coder committing a mistake is decreased.

Characteristics of strict mode in javascript:

Duplicate arguments are not allowed by developers.

Use of javascript’s keyword as a parameter or function name is


not allowed.

The 'use strict' keyword is used to define strict mode at the start of
the script. Strict mode is supported by all browsers.

Creating of global variables is not allowed.

1
Kailash G
What are the differences between
cookie, local storage and session
storage?

Cookie Local storage Session

Can be accessed on
Can be accessed on Can be accessed on
both server- side &
client- side only client- side only
client side

As configured using Lifetime is until Lifetime is until tab is


expires option deleted closed

SSL is supported SSL is not supported SSL is not supported

Maximum size is 4 KB Maximum size is 5 Maximum size is 5


MB MB

2
Kailash G
Explain prototype chaining
Prototype chaining is used to build new types of objects based on
existing ones. It is similar to inheritance in a class based language. The
prototype on object instance is available through
Object.getPrototypeOf(object) or __proto__ property whereas
prototype on constructors function is available through
Object.prototype

__proto__ __proto__ __proto__


Employee Person Object.prototype Null

What are generators and what


are its different kinds?
Introduced in the ES6 version, generator functions are a special class of
functions. They can be stopped midway and then continue from where
they had stopped. Generator functions are declared with the function*
keyword instead of the normal function keyword.
There are five kinds of generators,

Generator function declaration


Generator function expressions
Generator method definitions in object literals
Generator method definitions in class
Generator as a computed property

3
Kailash G
Difference between
Debouncing and Throttling.
Debouncing Throttling

Debouncing waits for a certain time before


An error has occurred in the eval() function
invoking the function again.

Ensures that the function is called only


An error has occurred with a number "out of
once, even if the event is triggered multiple
range”.
times.

Useful when you want to delay the


invocation of a function until a certain An error due to an illegal reference
period of inactivity has passed.

Eg. You can debounce an async API


request function that is called every time An error due to syntax
the user types in an input field.

Syntax:function debounce(func, delay{ let Syntax: function throttle(callback, delay =


timerId; return function () { 1000) {
const context = this; const args = let shouldWait = false; return (...args) => {
arguments; if (shouldWait) return;
clearTimeout(timerId); timerId = callback(...args);
setTimeout(function () { shouldWait = true;
func.apply(context, args); setTimeout(() => {
}, delay);
};
4 shouldWait = false; }, delay);
};
} }
Kailash G
Follow for more
great tips
Kailash G
@kailash1203

Thank you for your


great support!

Kailash G

You might also like