Javascript Imp Q&A
Javascript Imp Q&A
What is JavaScript?
JavaScript is a high-level, interpreted programming language used to create dynamic and
interactive web pages.
Dynamic typing
Prototypal inheritance
First-class functions
Closures
=== is the strict equality operator, which does not perform type coercion and checks both
value and type.
Event capturing is the propagation of an event from the top of the DOM tree down to the
target element.
What is closure in JavaScript?
A closure is a combination of a function and the lexical environment within which that
function was declared. It allows a function to access its outer scope even after the outer
scope has closed.
JavaScript Functions:
call(): Calls a function with a given this value and arguments provided individually.
What is a higher-order function in JavaScript?
A higher-order function is a function that takes another function as an argument or returns
a function as a result.
filter(): Creates a new array with elements that pass a test specified by a function.
reduce(): Executes a reducer function on each element of the array, resulting in a single
output value.
map(): Calls a function for each element in the array and returns a new array with the
results.
How do you access and modify elements in the DOM using JavaScript?
You can access and modify elements in the DOM using methods such as getElementById(),
getElementsByClassName(), querySelector(), and querySelectorAll(). You can then modify
element properties and attributes using JavaScript.
What is event delegation in JavaScript?
Event delegation is a technique where you attach an event listener to a parent element
rather than individual child elements. This allows you to handle events on dynamically
created or nested elements.
Event capturing: Events are first captured at the top of the DOM tree and then propagate
down to the target element.
JavaScript ES Features:
What are template literals in JavaScript?
Template literals are string literals that allow embedded expressions and support multi-line
strings.
Default exports: Allows you to export a single value from a module as the default export.
=========================================================================