Ayush Gupta has Published 556 Articles

What is event Bubbling and capturing in JavaScript?

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 07:23:57

Event bubbling is the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event (a click, for example). With bubbling, the event is first captured and handled by the innermost element and then ... Read More

Difference between push() and unshift() methods in javascript

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 07:06:55

The unshift method adds the element at the zeroeth index and shifts the values at consecutive indexes up, then returns the length of the array.The push() method adds the element at end to an array and returns that element. This method changes the length of the array.Examplelet fruits = ['apple', ... Read More

Difference between shift() and pop() methods in Javascript

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 07:03:11

The shift method removes the element at the zeroeth index and shifts the values at consecutive indexes down, then returns the removed value. If the length property is 0, undefined is returned.The pop() method removes the last element from an array and returns that element. This method changes the length ... Read More

Low level difference between Slice and Splice methods in Javascript

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 06:56:26

The basic difference between slice and splice is −splice() changes the original array on which it is called and returns the removed item(s) in an array as a new array object.slice() doesn't change the original array and also returns the array sliced.Example// splice changes the array let arr = [1, ... Read More

Difference between JavaScript deepCopy and shallowCopy

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 06:52:07

Shallow copy and deep copy are language agnostic. Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.Examplelet innerObj = {    a: 'b',    c: ... Read More

Radix sort in Javascript?

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 06:50:09

The radix sort algorithm distributes integers into buckets based on a number's significant digit or value (the radix). The radix is based on the number system of the values of the arrays. Let us look at how it can be implemented −Examplefunction radixSort(arr) {    // Find the max number ... Read More

Advertisements