The document provides a comprehensive overview of key JavaScript concepts, including accessing HTML input values, hoisting, event handling, and various array methods. It explains the differences between methods like slice and splice, the use of arrow functions, and the fetch method for retrieving resources. Additionally, it covers the distinctions between the DOM and Virtual DOM, as well as loop types and the ternary operator.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views2 pages
javascripti
The document provides a comprehensive overview of key JavaScript concepts, including accessing HTML input values, hoisting, event handling, and various array methods. It explains the differences between methods like slice and splice, the use of arrow functions, and the fetch method for retrieving resources. Additionally, it covers the distinctions between the DOM and Virtual DOM, as well as loop types and the ternary operator.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
javascript
1.How do you access the value of an HTML input element in JS?
To access the value of an HTML input element, use the value property of the input element's DOM object.
2.What is functions hoisting and variables hoisting?
Hoisting is JavaScript's process of moving variable and function declarations to the top of their scope before execution. With variable hoisting, only the declaration is hoisted, not the initialization. With function hoisting, both the declaration and definition are hoisted. This allows the use of functions and variables before they're declared.
3.What are the different types of events?
Some of the most common types of events are: Mouse Events: mousedown, mouseup etc Touch Events: touchstart, touchmove etc Keyboard Events keydown, keypress etc Form Events focus, blur, change, submit etc window events scroll, resize, load etc
4.What is a blur event in JavaScript?
A blur event in JavaScript occurs when an element such as textbox, button etc loses focus. To add a blur event listener, use either addEventListener with blur and function as arguments or the onblur property with function assigned. The function triggers when the element loses focus, and it's often used in form validations.
5.Explain about an event listener in JS?
An Event Listener listens for events like click, etc on element and triggers the event handler, which is a function to execute when an event occurs. To add an event listener, use the addEventListener method, providing the event type, such as 'click', and the function to execute when the event occurs.
6.What is preventDefault method?
The preventDefault() method is used to stop an event's default action. It's used within an event handler and called on the event object passed to the handler.
7.What are the most useful JavaScript array methods?
Some of the most useful JavaScript array methods are: push Adds items to the end of an array. pop: Removes the last item from an array and returns it. forEach: Executes a provided function once for each array item. It always returns undefined. map creates a new array with the results of calling the provided function for every item in array. filter creates a new array with all items that pass the condition in provided function. . \n splice changes the contents of an array by removing or replacing existing elements and/or adding new elements. slice: returns a new array with items from specified start index and end index of an array. shift: removes the first element of an array. unshift: adds one or more elements to the beginning of an array. sort sorts the items of an array and returns the sorted array. The default sort order is ascending.
8.What is the use of the push method in JavaScript?
The push method is used to add one or more items to the end of an array. Imagine an array of favorite colors containing red and blue, To add green at the end, use the push method and pass green. Now, the favoriteColors array contains red, blue, and green colors.
9.How to sort the numbers in an array?
By default, the sort method sorts items as strings. To sort numbers, pass a custom compare function as the argument. This function compares two elements, a and b, and sets their order in the sorted array. It arranges the numbers in ascending order. For example, if numbers array contains 100, 40, 60, using sort method with custom compare function, it becomes 40, 60, 100. 10.Explain about the array method slice? The slice method is used to get a part of an array. It returns a new array with items from a specified start index to an end index , without modifying the original array.
11.What are the differences between slice and splice?
slice is used to take a part of array without changing the original array, while splice is for adding, removing, or replacing items in the original array. slice accepts the start index and end index as optional parameters whole splice accepts start index and number of items to remove as required parameters and items to add/replace as an optional parameter
12.What is the use of a map method?
The map method is used to generate a new array by calling a provided function on each item of array. It does not modify the original array but instead returns a new array with the changed items. For example, suppose you have an array of numbers and want to create a new array containing the squares of these numbers. use the map method and pass a function that squares its argument. This will result in a new array containing the squared values of the original numbers.
13.Why do we use arrow functions?
Arrow functions offer a concise syntax for defining functions. They inherit "this" from the context in which they are defined.
14.What is the difference between Virtual DOM and DOM in JavaScript?
The DOM (Document Object Model) represents the structure of a web page, while the Virtual DOM is a copy of the DOM used for efficient updates. Interacting with the DOM can be slower, while the Virtual DOM is faster for changes because it optimizes updates.
15.What is the difference between 'for' and 'for...in' loops in JavaScript?
The "for" loop in JavaScript iterates sequentially over array or string elements, controlled by initialization, condition, and increment. The "for-in" loop iterates over the enumerable properties of an object in an arbitrary order.
16.What is the 'map' method?
The 'map' method allows for the iteration over an array, modifying its elements using a callback function. This method executes the callback function on each element of the array, creating a new array with the results.
17.What is an Anonymous function?
An anonymous function is a function without a name. These are commonly assigned to a variable or used as a callback function.
18.What is fetch method?
The fetch method is used to retrieve resources from the Internet. It returns a promise. We need to provide the fetch URL and request configuration options as parameters to the fetch method.
19.What is a ternary operator?
A ternary operator is a type of conditional operator that takes three operands: a condition to check, a result for true, and a result for false. It's a shorthand way of writing an "if-else" statement.
Principles of Forensic Audio Analysis 1st edition by Robert Maher 9783319994536 3319994530 - The newest ebook version is ready, download now to explore