Javascript Articles

Page 26 of 534

How to sort an array on multiple columns using JavaScript?

Abhishek
Abhishek
Updated on 20-Nov-2023 507 Views

A array with multiple columns is an array that contains multiple elements at single index or position OR we can say that it is an array of arrays that contains multiple arrays at each index of it and we have to sort that array according to the elements of those contained arrays. In this article, we are going to learn about the method of sorting an array of arrays with the help of sort() method. We will use the comparator function to compare the elements of inner arrays with each other and sort them accordingly. Let us see how we ...

Read More

How to sort an array of object by two fields in JavaScript?

Abhishek
Abhishek
Updated on 20-Nov-2023 460 Views

An array of objects is an array that contains all the elements in the form of JavaScript objects. Here, we are said to use an array of objects with two fields that means, have to use objects with two elements as elements of the array. In this article, we are going to learn about the method of sorting the array of objects by two fields in JavaScript. We can simply use the sort() method of JavaScript to sort the elements of an array and give it a cmp or the comparator function to define the order in which we want ...

Read More

How to sort a set in JavaScript?

Abhishek
Abhishek
Updated on 20-Nov-2023 550 Views

A set is also a data structure that is almost similar to the map data structure. The only difference between them is that map stores the elements in the form of key-value pair, while set does not it only stores a single value in the same order as it was inserted. It can also store primitive data types as well as objects as map does. A set contains all the elements in the same order as they are inserted. But, we can sort a set in any order whether in increasing or decreasing order of elements using the sort() method ...

Read More

How to sort a map in JavaScript?

Abhishek
Abhishek
Updated on 20-Nov-2023 2K+ Views

In JavaScript, Map is a type of data structure that stores the values in the form of key value pairs. It can store all types of data types, whether they are primitive or JavaScript objects. It stores the elements in the same order in which they are inserted, hence, when we iterate through its elements, it prints the elements in the same order as we have stored them. As we have discussed that the order of elements stored in a Map is same as we insert elements in that Map. But, we can also sort the elements of the map ...

Read More

How to solve the issue that arise while using performance.now() method in JavaScript?

Abhishek
Abhishek
Updated on 20-Nov-2023 282 Views

The performance.now() method is used to calculate the performance of the code written by any programmer or the coder. The performance.now() method will return a numerical value that will be the time taken by the written code to execute. The value returned by this method may vary every time we execute the code even for the same code. In today’s time, everyone wants to write the fast loading and the efficient code for a problem that can work on every parameter and fastest of all other solutions. So, to measure the efficiency and to make sure that the written code ...

Read More

ffmpeg settings for converting to mp4 and ogg for HTML5 video

Samual Sam
Samual Sam
Updated on 20-Nov-2023 2K+ Views

Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg.When converting to an MP4, you want to use the h264 video codec and the aac audio codec because IE11 and earlier only support this combination.   ffmpeg -i input.mov -vcodec h264 -acodecaac -strict -2 output.mp4In this example, input.mov is converted to output2.mp4 with maximum compatibility, with Quicktime support, and without an audio stream. ffmpeg -an -i input.mov -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 output2.mp4For Firefox compatible ogg video,  ffmpeg2theora should be installed.  Here the input file is output file from the ffmpeg conversion done before. ...

Read More

How to create a \"to-do list\" with CSS and JavaScript?

AmitDiwan
AmitDiwan
Updated on 17-Nov-2023 473 Views

A to-do list allows you to manage your task. It is like a note. When you type what needs to be done, for example, meeting at 4PM, you press Enter. On pressing Enter, the task gets added and a section for another task is visible wherein you can type the next task, example, lunch with a colleague at 7PM, etc. Add an Input Text to Enter a Task To add an input task, use the . A placeholder is also set using the placeholder attribute − Style the Input The input is set with the todoInput class. ...

Read More

How to create a \"coming soon page\" with CSS and JavaScript?

AmitDiwan
AmitDiwan
Updated on 17-Nov-2023 336 Views

We will create a coming soon page with a timer. The timer is set using the setInterval() function. The time is fetched using the getTime() function. Set the div We have set the image as a div class. Rest, the coming soon text and the timer is placed within it − COMING SOON Place the Image The image is now placed using the background-image property. The position is set using the background-position property” .bgimg { background-image: url("https://images.pexels.com/photos/117602/pexels-photo-117602.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"); height: ...

Read More

How to copy text to the clipboard with JavaScript?

AmitDiwan
AmitDiwan
Updated on 17-Nov-2023 646 Views

To copy text to the clipboard, we will use the HTMLInputElement methods, select() and setSelectionRange(). With that, we have also used the document execCommand() method to copy. Create an Input Text We will create an input text. This will the text that we will copy to the clipboard Set a Button We will click this button to copy the clipboard text − Copy text You can also style the button accordingly − button { border: none; outline: none; background-color: rgb(191, 187, 255); ...

Read More

How to Add CSS Rules to a Stylesheet with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Nov-2023 484 Views

The insertRule() helps us add a rule at a defined position in the stylesheet while deleteRule() deletes a specific style on a web page. The following examples illustrate CSS rules that can be added to a stylesheet using JavaScript. Insert a Rule To insert a rule at a defined position, use the insertRule() method. The margin, padding, and box-shadow is also set. First, the custom id is set using the getElementById() − let newSheet = document.getElementById('custom').sheet let cs = 'p {'; cs += 'margin: 4%;'; cs += 'padding: 2%;'; cs += 'font-size: 22px;'; cs += 'box-shadow: ...

Read More
Showing 251–260 of 5,338 articles
« Prev 1 24 25 26 27 28 534 Next »
Advertisements