-
JavaScript Shift() method
The shift() method removes the first item in an array and returns the removed value. This can be useful for removing items from the beginning of an array, or for getting the first item in an array without modifying the array itself.
-
JavaScript array push() method
The push() method adds one or more items to the end of an array and returns the new length of the array. This can be useful for adding items to the end of an array, or for combining multiple arrays together.
-
JavaScript array pop() method
The pop() method removes the last element from an array and returns the removed element. In the example above, the last element in the fruits array is “Mango”, which is removed by the pop() method and stored in the lastElement variable. After the pop() method is called, the fruits array is shortened by one element […]
-
JavaScript function
Introduction: What is a Javascript Function? A Javascript Function is a piece of code that performs a specific task when it is called. It takes one or more inputs and returns an output. Functions are useful for code reuse and organization. They can be used to break down a complex problem into smaller, manageable pieces. […]
-
What is Difference between substr() and substring() in JavaScript?
The difference between substr() and substring() in JavaScript is that substr() is used to extract a specified number of characters from a given string, starting from a specified position, while substring() is used to extract the characters from a string between two specified indices. substr() can accept negative index values, while substring() cannot. See below […]
-
JavaScript: String substr()
The JavaScript String substr() method returns a part of a given string, starting from the specified index and going up to the specified length. See below example
-
JavaScript: substring() method
The JavaScript String substring() method returns a subset of a string between two specified indices. This method extracts the characters in a string between two specified indices and returns the new sub string. See the below example
-
JavaScript Array reduce() Method
The JavaScript array reduce() method is used to reduce the elements of an array to a single value. It executes a provided function for each value of the array (from left-to-right). The return value of the function is stored in an accumulator (result/total). Syntax: Parameters: function(total, currentValue, currentIndex, arr) – A function to execute on […]
-
JavaScript Error
When coding in JavaScript, it is inevitable that you will encounter errors. However, understanding what these errors mean and how to troubleshoot them can be a challenge. In this article, we will discuss some of the most common JavaScript errors and how to debug them. Syntax Errors Syntax errors occur when the code you write […]
-
JavScript: filter() function
The JavaScript filter() function is used to iterate over array elements and create a new array that contains only elements that satisfy a certain criteria. This criteria is defined as a callback function which must return true or false. Every element in the array is passed through this function and each element that returns true […]