Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Front End Technology Articles - Page 575 of 860
How to remove the 0th indexed element in an array and return the rest of the elements in JavaScript?
854 Views
Array is a structure, which can hold values elements and they can be accessed by referencing to them with the help of index numbers. Const colors = [“Green”, “Maroon”, “Blue”]; Reference index of array In JavaScript arrays are referred with reference indexes. These indexes are zero-indexed. The very first element in the array will be 0 index. Second element will be index 1. Last element in the array will be the total size of the array minus 1. Spread operator (…) In this article, we are going to discuss how to remove the 0th indexed element in an ... Read More
510 Views
_.initial()_.initial() is a function in underscore.js, which is a library of javascript. This method is used to differentiate the last element of an array from the rest of the elements. This method just ignores the last value of an array.syntax_.initial( array, n );_.Initial() can take 2 parameters. array - The method takes the array and gives out all the elements except the last element.n - It is nothing but a number of elements that are to be trimmed from the given array. It is optional.ExampleLive Demo document.write(_.initial([1, 2, 3, 4, 5])); Output1, ... Read More
648 Views
_.size()_.Size() is from the underscore.js library of javascript. This is used to find the size of an array. One should make sure that before using this method one should use the CDN of the underscore.js to execute the code.syntax_.size(array);Example-1In the following example, a normal array is passed into _.size() method to get the size of the array.Live Demo var arr = [100, 62, 73, 534, 565]; document.write(_.size(arr)); Output5Example-2In the following example, an array that consists of object elements is sent into _.size() method to find the size.Live Demo ... Read More
234 Views
Math.hypot()Math.Hypot() method is used to find the square root of the sum of the squares of the elements that are passed to it as arguments. This method is actually used to find the hypotenuse of a right-angle triangle whose sides are passed as arguments into it. syntaxMath.hypot(arg1, arg2, ....);ExampleIn the following example, sides of a right-angle triangle are passed to find the hypotenuse. If any value is can't be converted to a number then NaN will be displayed as output. Live Demo document.write(Math.hypot(7, 24)); document.write(""); document.write(Math.hypot(7, "hi")); Output25 NaNThis ... Read More
30K+ Views
An event is defined as a change in an object's state. There are a number of events in HTML that show when a user or browser performs a certain action. JavaScript responds to these events when JavaScript code is embedded in HTML and allows execution. The process of responding to events is known as event handling. As a result, JavaScript uses event handlers to handle HTML events. In this article, we are going to discuss how to remove event handlers in JavaScript. Here, we use the removeEventListener() method to remove an event handler from an element in JavaScript. Using the ... Read More
332 Views
Events in HTML are “things” that take place using HTML elements. JavaScript can “respond” to these events when used in HTML pages. Events are produced as a result of user interaction with the elements of the user interface. The actions that trigger an event include, for instance, pressing a button, moving the mouse, typing a character on the keyboard, choosing an item from a list, and scrolling the page. Examples of HTML events are mentioned below − An HTML web page has finished loading An HTML input field was changed An HTML button was clicked Adding an event ... Read More
2K+ Views
Yes, it is possible to change the content of the HTML in javascript. Usually HTML content will be in HTML tags such as , , etc. In javascript, we have DOM methods that have an ability to access the HTML tags. Those methods, such as document.getElementById(), document.getElementByTagName(), etc., make use of tags to change the HTML content.Example-1In the following example, the content in the span tag is changed using a javascript DOM method document.getElementById(). Live Demo Is javaScript is java. Once the above code is executed, we will get the following on the screen If we click ... Read More
1K+ Views
In this article, we are going to discuss how to convert a string to a floating-point number in JavaScript. We can convert a string to a floating point in three ways − Using the parseFloat() method. Using the parseInt() method. Using type conversion. Using the parseFloat() method The parseFloat() is a function in JavaScript, this accept the string as input and convert the value into a floating point number. Let’s consider a scenario where there is numeral value in the string and also if the first character of the string is not a number then the resultant output ... Read More
326 Views
_without() This method is in the underscore.js library of javascript. It takes two parameters and removes, what are the elements present in the second array, from the first array. It doesn't bother whether the values are true or false, it checks each value one by one and proceeds the task. Make sure that it is case sensitive.syntax_.without( array, values);ExampleIn the following example, it checks whether the values present in the second parameter are in the first parameter or not and tries to remove the available values. Live Demo document.write(_.without([5, 6, 4, 8, 9, 9, 0, 1], 0, ... Read More
191 Views
In this article, we are going to discuss whether provided elements in an array have passed a specified condition or not in JavaScript. Here, we can use the _.filter() method, every() method, some() method, filter() method, and for loop. They return true if every element in an array has met the condition, otherwise, they return false. Using the Array.filter() method This Array.filter() method is a JavaScript function. Array.filter() method will be creating a new array containing the elements that are passed in the condition which is defined by function in program. This Array.filter() method will not execute if elements are ... Read More