
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
Web Development Articles - Page 566 of 1049

273 Views
The array.flatMap() method of JavaScript is used to flatten the input array element into a new array.The syntax is as follows − array.flatMap(function callback(current_value, index, Array))Let us now implement the array.flatMap() method in JavaScript −Example Live Demo Ranking Points Is any point equal to 550 from the key-value pairs... Result var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000]; var res = pointsArr.flatMap(val => [val + 10]).entries(); for (val of res) { document.getElementById("test").innerHTML += ... Read More

157 Views
The array.entries() method of JavaScript is used to return an Array Iterator object with key/value pairs.The syntax is as follows − array.entries()Let us now implement the array.entries() method in JavaScript −Example Live Demo Ranking Points Is any point equal to 550 from the key-value pairs... Result var pointsArr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1000]; var res = pointsArr.entries(); for (val of res) { document.getElementById("test").innerHTML += val + ""; } ... Read More

190 Views
The from() method of JavaScript is used to return the Array object from any object with a length property or an iterable object.The syntax is as follows −Array.from(obj, mapFunction, val)Above, the parameter obj is the object to convert to an array, mapFunction is a map function to call, val is a value to use as this when executing the mapFunction.Let us now implement the from() method in JavaScript −Example Live Demo Demo Heading var arr1 = Array.from("PQRS"); var arr2 = Array.from("12345"); document.getElementById("test").innerHTML = arr1 ... Read More

805 Views
The findIndex() method of JavaScript is used to return the index of the first element in an array, if the condition is passed.The syntax is as follows −array.findIndex(function(currentValue, index, arr), thisValue)Let us now implement the findIndex() method in JavaScript −Example Live Demo Rank Result Finding the index of the player with highest rank. var points = [100, 150, 200, 250, 300, 400]; function topRank(points) { return points >= 400; } function display() { ... Read More

406 Views
The fill() function is a built-in function of JavaScript which is used to fill all the elements of an array with a static value. This function modifies the original array and returns the modified array. The fill() function of JavaScript is a simple and basic function used to fill an array with a specified function. In this article, you will understand the usage and functionality of the fill() function of JavaScript. Syntax The basic syntax of the fill() function is mentioned below: array.fill(val, start, end) Let's understand the parameters used in the fill() function. ... Read More

365 Views
The find() method of JavaScript is used to return the first elements value in an array, if the condition is passed, otherwise the return value is undefined. The syntax is as follows −array.find(function(val, index, arr), thisValue)Here, function is a function with val, which is the value of the current element. The index is the array index, and arr is the array. The this value parameter is the value to be passed to the function.Example Live Demo Ranking Points Get the points (first element) above 400... Result var pointsArr = ... Read More

1K+ Views
Object literals and constructors both are used to create an Object in JavaScript. An object created by the object literals is a singleton. This means when a change is made to the object, it affects that object across the entire script. If an object created by a function constructor has multiple instances of the object. This means the changes made to one instance, will not affect other instances. Object Literal Notation − Let’s create user details where we have the key, name, age, and name of the company. So we are creating an object named userDetails. const userDetails = {name: "Aman", ... Read More

1K+ Views
In computer programming, cloning refers to an object copied by a method or copy factory function often called clone and copy. The easiest way to clone an object except for one key would be to clone the whole object and then remove the property that is not required. Cloning, however, can be of 2 types − Deep Clone Shallow Clone Shallow Clone The shallow clone copies as little as possible. For example, a shallow copy of a collection might be a copy of the collection’s structure, not its elements. With a shallow copy, two collections now share individual ... Read More

4K+ Views
In this article, we are going to discuss how to convert a string value to a Date object in JavaScript. There are two ways to achieve this − Using the constructor of the Date class − This constructor accepts a string value representing the date value, converts it into a Date object, and returns the result. Using the Date.parse() method − Same as the Date constructor this method accepts a string value parses and returns the date value in the form of milliseconds. Let us see these solutions with examples − Using the Date() constructor The most commonly used way ... Read More

930 Views
In this article, you are going to learn how to insert a string at a position in another string. JavaScript does not give a direct way to achieve this. For this, we can use the slice method. The slice method extracts a section of a string and returns a new string. In addition to the slice() method we can also use the methods join() and substr(). Using the slice() Method of the String class This slice() method gets parts of the string and returns the extracted part from the string and makes a new string. Following is the syntax ... Read More