Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 42 of 80

How to use map() on an array in reverse order with JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 4K+ Views

We have given the array of elements and need to use the map() on the array in reverse order with JavaScript. The map() method maps the new element related to a particular array element in the resultant array. Sometimes, we require to map the elements in reverse order. There can be many ways to use map() on an array in reverse order. We will see all approaches one by one. Introduction to map() method Syntax Follow the syntax below to use the map() method. array.map((ele, ind, array) => { return ele + 20; }) ...

Read More

How to use map and filter simultaneously on an array using JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 5K+ Views

The filter() method is used to filter values from the array, and the map() method is used to map a new value to another array based on every value of the old array. Sometimes, we require to use the filter() and map() methods together. For example, we wanted to filter all positive numbers from the array and map their logarithmic value to the new array Let’s look at the introduction of the filter() and map() methods before we start with this tutorial. In this tutorial, we will learn to use the map and filter methods simultaneously on an array ...

Read More

How to use the JavaScript function in the check box?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 15K+ Views

While working with the HTML checkboxes, sometimes developers may require to use the checkboxes to allow users to select multiple options. Also, developers need to perform some actions based on the selected checkbox. For example, you have given the checkbox with a question like are you above 18? If users check this checkbox, only show the input to take a user’s pan card number. So, we need to call a function whenever the user checks and unchecks the checkboxes. Use the onchange event The onchange event attribute allows us to invoke a function whenever the user checks and ...

Read More

How to unpack array elements into separate variables using JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 1K+ Views

Unpacking array elements means assigning array element values to the new variables. We can assign every element to the separate variables, or we can assign some elements to the separate variables, and for the remaining elements, we can create a new array. In this tutorial, we will learn to unpack array elements into separate variables using JavaScript. Syntax Users can follow the syntax below to unpack the array elements into separate variables. let array = [element1, element2, element3, element4]; let [a, b, c, d] = array; In the above syntax, a variable contains the value of element1, ...

Read More

How to trim a file extension from a string using JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 9K+ Views

Many web applications allow users to upload a file. Also, it shows the file content with the filename after trimming the file extension. Furthermore, sometimes we require to store the file's content in the database with the filename without extension as a key. So, various use cases require us to use the file name of the uploaded file without extension. Here, we will learn multiple ways to trim the file extension from the string using JavaScript. Use the array.split(), array.pop() and array.join() method Every file name contains the file extension after the last dot in the file name. ...

Read More

How to swap the key and value of JSON element using JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 3K+ Views

Here, we will learn to swap the key and value of the JSON element using JavaScript. In JavaScript, an object stores the key-value pairs. So, we can swap the key and value as we swap two normal variables. In this tutorial, we will learn different approaches to swapping all the key values of JSON elements using JavaScript. Use the for loop We can iterate through the keys of the JSON object using for loop. After that, we can access the value from the object using the key. So, we can swap every key and value in the object. ...

Read More

How to store all dates in an array present in between given two dates in JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 3K+ Views

Sometimes, we require to get all the dates between the given date range. In this tutorial, we will take two dates and find all dates between two dates. Also, we will store all dates in the array. Here, we will learn three approaches to storing all dates in an array present between given two dates in JavaScript. Use the while loop and setDate() method We can use the while loop for iteration and the setDate() method to set dates in the date object. On every iteration of the while loop, we can increase the date by one ...

Read More

How to store a key => value array in JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 6K+ Views

Sometimes, we require to map keys to particular values using some data structure in JavaScript. For example, storing the user details in the key value pairs in JavaScript is useful. We can use different data structures, such as objects or maps in JavaScript, to store data in the key-value format. Use the objects to store a key => value in JavaScript In JavaScript, objects allow us to store data in the key-value format. We can use the key with the object to get the data from the object. Syntax Users can follow the syntax below to use ...

Read More

How to stop browser's back button using JavaScript?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 15K+ Views

Stopping the browser’s back button meaning is that preventing users from going to the previous page. Sometimes, we need to prevent users from going to the back of the current page for security purposes. For example, most bank sites don’t allow you to go back when you are doing some transaction from their site using online banking. Because if users go back from the midtransaction, it can create some issues. So, it only allows you to either complete the transaction or cancel the transaction and start it again. Here, we will learn various approaches to prevent users from going ...

Read More

How to communicate JSON data between C++ and Node.js ?

Shubham Vora
Shubham Vora
Updated on 16-Feb-2023 2K+ Views

C++ is a powerful, high-performance language widely used for system-level programming and applications. At the same time, Node.js is an open-source, cross-platform JavaScript runtime environment commonly used for web applications. By understanding the various methods for communicating JSON data between C++ and Node.js, developers can choose the best approach to their specific needs. In this tutorial, we will explore the various ways to communicate JSON data between a C++ application and a Node.js server. Three common approaches: using a RESTful API, using a message queue, and using a WebSocket Users can follow the steps below to communicate JSON data between ...

Read More
Showing 411–420 of 793 articles
« Prev 1 40 41 42 43 44 80 Next »
Advertisements