ea) ae
\ a
Javascript series-PART56 ae
‘Advanced ah
Da pentat
i eats
5 : \ 3
Preeienntereh yas >
Naishnavi bairagi ry
aoag . 03/10
1. Explain the difference between Object.freeze()
vs const
const and Object.freeze are two different functions in
Javascript. const applies to bindings variables. It creates
an immutable binding, which means it is not possible to
assign a new value to the binding.
Object.freeze works on object values. It makes an object
immutable, which means changing its properties is not
possible. .
2. Explain NaN and its role
When a value in an operation is not a number, it returns NaN.
It may occur in a few instances. For example, if an operation
can return a suitable output because a portion of the function
was non-numeric or the result has a value that is not numeric.
ProgrammingIDSAlWeb-developmentgS 04/10
3. Explain arrow functions
An arrow function is a concise way to write function
expressions. Arrow functions are not constructors and
do not support the keywords this, arguments, super or
new.target. It is best suited for functions that are not methods.
4. Explain the JavaScript event delegation
model
Instead of specifying nodes, event delegation enables you
to add event listeners to a single parent. This listener
analyses bubbled events to locate a match on the child
elements.
Programming|DSAlWeb-developmentBy 05/10
5. Explain Javascript cookies
Cookies are the tiny text files that are properly stored in
a computer and they develop when the user goes to the
websites to store some information that they require.
Examples are username details and information about
the shopping cart content from earlier visits.
6. What is the use of break and continue
statements in JavaScript?
The break statement jumps out from a running loop,
whereas the continue statement allows the loop to keep
running after breaking just one iteration.
Programming|DSA|Web-developmentEe 06/10
7. What is the significance & benefits of including
“use strict” in JS file.
The "use strict" is not a statement, rather a literal expression
that is vital to your code as it presents a way for voluntarily
enforcing a stricter parsing and error handling process on
your JavaScript code files or functions during runtime. Most
importantly, it just makes your code very easy to manage.
8. What is the use of weakmap object in JS?
The WeakMap object is basically a collection of key or value
pairs where the keys are weakly referenced. It provides a way
for extending objects from the outside without meddling into
the garbage collection.
Programming|DSAlWeb-developmentgg 07/10
9. What is asynchronous programming and why
it is needed?
Asynchronous programming means that the program engine
runs in an event loop. Only when blocking operation is required,
a request is started, and the code runs without blocking the
result.
This is vital in JavaScript because it is a very natural fit for
the user interface code and very efficient performance-wise
on the server end.
10. What is the drawback of creating true private
method in javascript?
One of the drawbacks of creating a true private method in
Javascript is that they are highly memory consuming. A new
copy for each method is created for every instance.
Programming|DSAlWeb-developmentfe) 08/10
11. What is temporal dead zone in ES6.
In ES6, Temporal Dead Zone is a behavior occurring in
Javascript while declaring a variable with the let and const
keywords. The period between entering the scope and being
declared is the one when these keywords cannot be accessed
and enter the Temporal Dead Zone.
12. Why is ‘this’ operator inconsistent in javascript.
In JavaScript, this operator always refers to the object, which
is invoking the function being executed. So, if the function is
currently being used as an event handler, this operator will
refer to the node which fired the event.
Programming|DSAlWeb-developmentee 09/10
13. What is the difference between map() & filter()
in javascript.
The map function returns the same number of elements as
present in the original array but the value of elements will be
transformed in some way.
filter function can return fewer or more elements than the
original array but the value of the original elements will not
change.
14. What is currying in javascript.
It is an advanced technique of working with functions that
can accept multiple arguments. It will transform this function
into a series of functions, where every function will accept
one argument:
Programming|DSAlWeb-development