Javascript Articles

Page 263 of 534

What are the characteristics of JavaScript 'Strict Mode'?

Arnab Chakraborty
Arnab Chakraborty
Updated on 22-Aug-2022 448 Views

This tutorial will explain you what are the different characteristics of JavaScript 'Strict Mode'. As such, there are two different modes of programming in JavaScript. By default, the simple mode or sometimes known as the sloppy mode is enabled. In this mode, we do not need to follow strict rules while writing the code. On the other hand, the strict mode is also there. This mode enables some strict rules in the environment. Strict mode is not a subset of the sloppy mode but it also has different semantics than normal code. Syntax Strict modes can be ...

Read More

How to convert a decimal number to roman using JavaScript?

Shubham Vora
Shubham Vora
Updated on 22-Aug-2022 908 Views

Roman numerals are a type of number system used to represent a fixed decimal number. Several letters from the Latin alphabet are used for the representation of roman numerals. In this tutorial, the user will learn how to convert a decimal number to roman using JavaScript. Seven symbols represent Roman numerals: I, V, X, L, C, D, and M. The values for symbols are given below. Syntax I is 1 V is 5 X is 10 L is 50 C is 100 D is 500 M is 1000 Using these seven symbols user can convert decimal numbers to roman. ...

Read More

How and why does 'z'['toUpperCase']() in JavaScript work?

Shubham Vora
Shubham Vora
Updated on 22-Aug-2022 310 Views

In this tutorial, we will learn how and why ‘z’[‘toUpperCase’]() works in JavaScript. From the given format, we can say that it calls the toUpperCase() method for the ‘z’ string. It will work the same as the toUpperCase() method, which we invoke by taking any string as a reference. Let’s understand the syntax of the ‘z’[‘toUpperCase’]() below. Syntax let result = 'z'['toUpperCase'](); // returns 'Z', string in upper case The above syntax is same as the below. Example let string = 'z'; let result = string.toUpperCase(); Why does ‘z’[‘toUpperCase’]() work? In JavaScript toUpperCase() method is used to convert ...

Read More

Can I declare JavaScript variables as specific types?

Shubham Vora
Shubham Vora
Updated on 22-Aug-2022 3K+ Views

In this tutorial, we will see if we can declare JavaScript variables as a specific type or not. The JavaScript contains the three reserve keywords to declare the variables: ‘let, ’ ‘var’, and ‘const.’ When the user declares the variable using any keyword, it has a different scope. The variable declared with the const keyword always remains constant, and we can’t change its value after initializing it. The variables declared with the let keyword have block scope and can’t be accessed outside its scope. When we declare the variables with the var keyword, it can have the global scope or ...

Read More

How to convert Unicode values to characters in JavaScript?

Shubham Vora
Shubham Vora
Updated on 22-Aug-2022 6K+ Views

In this tutorial, we will learn to convert Unicode values to characters in JavaScript. The Unicode values are the standard values for the character, and users can encode them to convert them into characters. For example, ‘A’ is a Unicode character whose value is 65 according to the ASCII (American standard code for information interchange) table. In the same way, all alphabets, numbers, and other characters have particular Unicode values. We will learn to identify the Unicode character from its values using JavaScript. Using the fromCharCode() Method In JavaScript, the string library contains the fromCharCode() method, which takes the decimal ...

Read More

How to convert an array into JavaScript string?

Shubham Vora
Shubham Vora
Updated on 22-Aug-2022 8K+ Views

An array is the most popular and adaptable data structure you might employ in your regular programming. Predefined methods and a few more techniques make converting an array into a string simple. The process of converting an array into a JavaScript String can be done in several methods, and in this article, we will be looking at them. Using the toString() Method Using the join() Method Using JSON.stringify() Method Using the Type Coercion Using the toString() Method There is an internal function toString(). It is a built-in JavaScript method that can be applied to any JavaScript variable. The ...

Read More

How to add 30 minutes to a JavaScript Date object?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 22-Aug-2022 12K+ Views

In this tutorial, we will learn how to add 30 minutes to a JavaScript Date object. Here we will discuss two methods which are following. Using the setMinutes( ) Method Using the getTime() Method Using the setMinutes Method The setMinutes() function of the date object accepts an integer representing the Minutes and replaces the value of the Minutes in the current date with it. Syntax Date.setMinutes(min, sec, ms); Parameter min − An integer between 0 and 59, representing the minutes. sec − An integer between 0 and 59, representing the seconds. If you specify the sec ...

Read More

How to add number of days to JavaScript Date?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 22-Aug-2022 19K+ Views

In this tutorial, we will learn how to add a number of days to a JavaScript Date object. Here we will discuss two methods which are following. Using the setDate( ) Method Using the getTime() Method Using the setDate( ) Method JavaScript date setDate() method sets the day of the month for a specified date according to local time. Syntax Its syntax is as follows − Date.setDate( dayValue ) Here dayValue is an integer from 1 to 31, representing the day of the month. Approach To add a number of days to the current date, first we ...

Read More

How to add many Event Handlers to the same element with JavaScript HTML DOM?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 22-Aug-2022 13K+ Views

It is very common to use the events while we are programming in JavaScript. Suppose you are creating a modal that opens up on clicking a button or hovering over using the cursor, here we using two events on a single element but JavaScript does not have any official way to use many event listeners on a single element. In this article, we will learn How to add many Event Handlers to the same element with JavaScript HTML DOM. To achieve this, we have the following approaches given below. Using Multiple addEventListener Methods Using the ES6 Way Using ...

Read More

How to add hours and minutes to a date with JavaScript?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 22-Aug-2022 12K+ Views

In this tutorial, we will learn how to add hours and minutes to a date with JavaScript. We have multiple methods to achieve this which are the following. Add hours using the setHours() Method. Add minutes using the setMinutes() Method. Add hours or minutes with the getTime() Method. Add hours using the setHours Method JavaScript date setHours() method sets the hours for a specified date according to local time. Syntax Following is the syntax to apply the setHours() method to add hours to date − Date.setHours(hours, minutes, seconds, ms) Note − Parameters except the first one are ...

Read More
Showing 2621–2630 of 5,338 articles
« Prev 1 261 262 263 264 265 534 Next »
Advertisements