Found 6685 Articles for Javascript

How to open a webcam using JavaScript?

Kalyan Mishra
Updated on 23-Aug-2022 12:02:44

18K+ Views

In this tutorial, we will learn about the procedure to open a webcam using JavaScript. So, this can be done using WebRTC. WebRTC is a short form of Web Real-Time Communication. Using this object, we can access and capture the Webcam and Microphone devices that are available there in the user device. How to Access Webcam? We can access the user device Webcam and microphone using an ECMAScript object navigator.mediaDevices.getUserMedia(constraints). So, the getUserMedia() function by default seek user permission to use your Webcam. This function returns a promise and once you click ok and give the permission then the promise ... Read More

How to check if the value is primitive or not in JavaScript?

Kalyan Mishra
Updated on 23-Aug-2022 11:25:01

3K+ Views

In this tutorial, we are going to know the methods to check if the given data type is primitive or not. Datatypes in JavaScript 1. Primitive 2. Non-primitive Primitive data types − String, number, undefined, boolean, null, symbols, bigint. Non-primitive data types − Object A primitive datatype/value is something that is not an object, and it is represented at the bottom level of the language implementation. All primitive values are immutable which means that you cannot change their type instead you may reassign v new value to the variable. To check if the value is primitive or not, we check ... Read More

How to create an element from a string in JavaScript?

Kalyan Mishra
Updated on 23-Aug-2022 11:20:05

2K+ Views

In this tutorial, we will get to know about various methods to create an element from strings in JavaScript. Creating elements from a string can be very useful in case we have to generate elements dynamically which makes the website interactive. An example will be like in a to-do list app we add, delete, and edit to-do items. The createElement() Method We create JavaScript items using the createElement() method. To create a particular element, we pass the item name as a string into the createElement() method. The createElement(tagName) function has a parameter as the name of the tag which will ... Read More

How to create notes taking app using HTML, Bootstrap and JavaScript?

Kalyan Mishra
Updated on 23-Aug-2022 11:17:36

432 Views

In this tutorial, we will make a notes-taking app using HTML, Bootstrap, and JavaScript. So, the HTML will use here to add different-different elements, bootstrap will be working here to beautify our design like CSS, and JavaScript will be adding basic functionality like adding and deleting our notes. Let’s see our HTML design of the UI. Our UI will contain a simple text area where we will enter our desired note, a button which will use to add our given note to the list of notes and in the list of notes there will be a delete button on each ... Read More

How to create a string by joining the elements of an array in JavaScript?

Kalyan Mishra
Updated on 23-Aug-2022 11:10:01

487 Views

In this tutorial, we will see how to create a string by joining the elements of an array in JavaScript. We will see two different approaches to doing this task. The first approach is using a simple addition operator (+) to add the elements of the array and separator. The second approach is to use the join() method. Approach 1: Using the Addition Operator (+) In this approach, we will pass two parameters to the function the array of which elements we have to Join, and the second parameter will be the separator that the user has to give, basically, ... Read More

How to create a revealing sidebar using HTML, CSS, and JavaScript?

Kalyan Mishra
Updated on 16-Aug-2022 08:12:02

1K+ Views

In this tutorial, we will see different approaches to finding unique characters in a string. Simply say when a character once occurred in the string then it will not be included in the string again. Approach We will follow the below steps to create our design − STEP 1 − We will create our necessary HTML elements like home, icon, dashboard, and more options which will be present inside the sidebar. STEP 2 − Then we will design our HTML elements using CSS and we will fix them at their correct positions, in this tutorial we will use internal CSS ... Read More

What are the different use cases of remainder operator (%) in JavaScript?

Kalyan Mishra
Updated on 16-Aug-2022 08:07:00

326 Views

In this tutorial, we will see the different use cases of the remainder operator (%). The % operator is also known as the modulo operator. This operator returns the remainder when a number is divided by the second. It takes the sign of the dividend. What is Remainder? From the division formula dividend / divisor = quotient quotient. When the dividend is not completely divisible by the divisor then there is always a remainder. So, in case our quotient is an integer then our remainder will always be zero. For example 10 / 2= 5 here no remainder is there ... Read More

How to design a Loan EMI Calculator using HTML, CSS and JavaScript?

Kalyan Mishra
Updated on 16-Aug-2022 07:58:50

8K+ Views

In this tutorial, we will learn about the design and working of a loan calculator using JavaScript. This calculator will simply tell us about our monthly EMI based on the loan amount, interest rate, and month. We will make the UI using HTML and will apply the styling using internal CSS then we will apply the functionality to calculate EMI using JavaScript. HTML Firstly, we will create a div block that will have three input boxes. All the boxes will be for the loan amount, rate, and time respectively. Then a button and an output field will be there for ... Read More

How to truncate an array in JavaScript?

Kalyan Mishra
Updated on 16-Aug-2022 07:22:09

2K+ Views

This tutorial is going to be about truncating an array in JavaScript. Truncating an array means trimming some elements from the end and assigning back the new value of the truncated array to the actual array. Sometimes we need to truncate an array. Suppose in a case, there is an array in which sorted (descending order) elements are there, and now we need only the first k sorted element from the array and delete the else value. So we don’t need to create an extra array and modify that and assign it to the actual. There are many ways to ... Read More

What is Promise Chaining in JavaScript?

Kalyan Mishra
Updated on 16-Aug-2022 07:17:48

998 Views

In this tutorial, we will talk about promise chaining in JavaScript. Before moving to promise to chain let’s first talk about what is Promise So, as we know JavaScript is single-threaded which means that no two functions will be allowed to run at the same time as we have only one call stack like below which has a function to execute when one function completes its execution then another function starts executing so to achieve two or more functions running at the same time we use asynchronous programming in JavaScript example- setTimeout function which takes a call-back function and specified ... Read More

Advertisements