• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

Advanced JavaScript Questions with correct answers 100%

Document preview thumbnail
Preview 2 out of 7 pages

Advanced JavaScript Questions with correct answers 100% What are Function Overloads in TypeScript? - Correct Answer If a function accepts more than 1 type of parameter, overloads can help us deal with each specific parameter type. What are closures in JavaScript and how are they used? - Correct Answer Closure or "Closed Over Variable Environment" is a concept in JavaScript when a function maintains access to its lexical scope. For example if we have a high order function Parent that returns a function called Child. Child will have an access to Parent's variable environment even after Parent's execution context has been popped off from the call stack.¡ Explain the concept of hoisting in JavaScript - Correct Answer Hoisting is happening during the compilation time when the scopes are being defined. JS compiler, goes through the code and looks for variable and function declarations. The function declarations and variables declared with the keyword var are initialised and thus can be used before in previous lines as well (however, var is initialised with undefined). The variables declared with let and const are moved to TDZ (Temporal Dead Zone) instead. If we try to use them before the line where they are declared we'll get a TDZ error. How does prototypal inheritance work in JavaScript? - Correct Answer Prototypal inheritance or prototypal linking is a way of sharing properties across objects in JavaScript. Every object (arrays, objets and functions) has a constructor to which it is linked with __proto__ property. When accessing a property of an object, if the property is not found on the object itself, JavaScript will look up the prototype chain to find it. This is fundamentally different from classical inheritance where the properties are copied from the classes, in JS they are linked. What is event delegation in JavaScript and why is it useful? - Correct Answer Event delegation is a technique where instead of attaching event listeners to individual child elements, you attach a single listener to a parent element. This listener manages all events that bubble up from the child elements. It's useful for handling events on dynamically added elements, optimising performance, and reducing memory usage by minimising the number of event listeners. Explain the concept of a single-threaded environment in JavaScript. - Correct Answer JavaScript is single-threaded, meaning it can only execute one command at a time in a single main thread. Despite this limitation, it can perform non-blocking operations using asynchronous callbacks and the event loop, allowing for efficient execution of tasks without freezing the user interface. How do you optimize website performance with respect to JavaScript? - Correct Answer To optimise website performance: minimise and compress JavaScript files; defer loading of non-critical scripts; use asynchronous loading for scripts; optimise and reduce DOM manipulations; leverage browser caching; use efficient algorithms and data structures; and avoid memory leaks. What are some security concerns with JavaScript and how do you address them? - Correct Answer Common JavaScript security concerns include cross-site scripting (XSS), cross-site request forgery (CSRF), and code injection. To mitigate these, use content security policies (CSP), validate and sanitize all user input, use HTTPS, and avoid eval() and other dangerous functions that execute code from strings. Explain the concept of the Document Object Model (DOM). - Correct Answer The Document Object Model (DOM) is a programming interface provided by browsers that represents a webpage as a tree of objects. It allows scripts to dynamically

Content preview

Advanced JavaScript Questions with
correct answers 100%
What are Function Overloads in TypeScript? - Correct Answer If a function accepts
more than 1 type of parameter, overloads can help us deal with each specific parameter
type.

What are closures in JavaScript and how are they used? - Correct Answer Closure or
"Closed Over Variable Environment" is a concept in JavaScript when a function
maintains access to its lexical scope.

For example if we have a high order function Parent that returns a function called Child.
Child will have an access to Parent's variable environment even after Parent's execution
context has been popped off from the call stack.¡

Explain the concept of hoisting in JavaScript - Correct Answer Hoisting is happening
during the compilation time when the scopes are being defined. JS compiler, goes
through the code and looks for variable and function declarations. The function
declarations and variables declared with the keyword var are initialised and thus can be
used before in previous lines as well (however, var is initialised with undefined). The
variables declared with let and const are moved to TDZ (Temporal Dead Zone) instead.
If we try to use them before the line where they are declared we'll get a TDZ error.

How does prototypal inheritance work in JavaScript? - Correct Answer Prototypal
inheritance or prototypal linking is a way of sharing properties across objects in
JavaScript. Every object (arrays, objets and functions) has a constructor to which it is
linked with __proto__ property. When accessing a property of an object, if the property
is not found on the object itself, JavaScript will look up the prototype chain to find it. This
is fundamentally different from classical inheritance where the properties are copied
from the classes, in JS they are linked.

What is event delegation in JavaScript and why is it useful? - Correct Answer Event
delegation is a technique where instead of attaching event listeners to individual child
elements, you attach a single listener to a parent element. This listener manages all
events that bubble up from the child elements. It's useful for handling events on
dynamically added elements, optimising performance, and reducing memory usage by
minimising the number of event listeners.

Explain the concept of a single-threaded environment in JavaScript. - Correct Answer
JavaScript is single-threaded, meaning it can only execute one command at a time in a
single main thread. Despite this limitation, it can perform non-blocking operations using
asynchronous callbacks and the event loop, allowing for efficient execution of tasks
without freezing the user interface.

, How do you optimize website performance with respect to JavaScript? - Correct Answer
To optimise website performance: minimise and compress JavaScript files; defer
loading of non-critical scripts; use asynchronous loading for scripts; optimise and reduce
DOM manipulations; leverage browser caching; use efficient algorithms and data
structures; and avoid memory leaks.

What are some security concerns with JavaScript and how do you address them? -
Correct Answer Common JavaScript security concerns include cross-site scripting
(XSS), cross-site request forgery (CSRF), and code injection. To mitigate these, use
content security policies (CSP), validate and sanitize all user input, use HTTPS, and
avoid eval() and other dangerous functions that execute code from strings.

Explain the concept of the Document Object Model (DOM). - Correct Answer The
Document Object Model (DOM) is a programming interface provided by browsers that
represents a webpage as a tree of objects. It allows scripts to dynamically access and
update the content, structure, and style of a document. The DOM is constructed as the
page loads, and JavaScript can be used to manipulate it, creating an interactive user
experience. The DOM represents the document as nodes and objects; this way,
programming languages can interact with the page. It is language-independent and can
be used with languages like JavaScript, Python, etc. An advanced aspect of the DOM is
its event propagation model, which includes capturing and bubbling phases.
Manipulating the DOM can also lead to reflows and repaints, impacting performance. As
such, understanding how to interact with the DOM efficiently, such as minimizing DOM
manipulations and avoiding unnecessary reflows, is crucial for advanced JavaScript
development.

What is the purpose of the bind method in JavaScript? - Correct Answer The bind
method is used to explicitly set the context of 'this', it returns a new function. It was used
more commonly before the introduction of arrow functions to make sure the 'this' context
was set correctly.

What is TypeScript and how is it different from JavaScript? - Correct Answer
TypeScript is a superset of JavaScript that adds static typing and some other features
not found in plain JavaScript. The main difference is that TypeScript offers static type
checking, which means errors can be caught at compile time rather than runtime.
TypeScript is compiled into plain JavaScript, making it compatible with any browser,
host, or OS.

What are TypeScript Generics and why are they useful? - Correct Answer Generics in
TypeScript are dynamic types whose value change depending on the context. They're
useful when creating generic functions that can accept different types as arguments.

Can you explain the difference between an interface and a type in TypeScript? - Correct
Answer In TypeScript, both interfaces and types define object shapes and function
signatures, but they differ in key ways. Interfaces are more extensible and support
declaration merging, allowing multiple declarations with the same name to merge into

Document information

Uploaded on
November 1, 2025
Number of pages
7
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$9.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Wairimumburia
3.5
(2)
Sold
25
Followers
3
Items
2826
Last sold
1 week ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions