Javascript Articles - Page 587 of 671

How to return a string value version of the current number?

Manikanth Mani
Updated on 23-Jun-2020 08:42:43

232 Views

The toLocaleString() method returns a string value version of the current number in a format that may vary according to a browser's local settings.ExampleYou can try to run the following code to return a string value version −           JavaScript toLocaleString() Method                        var num = new Number(150.1234);          document.write( num.toLocaleString());          

How to force a number to display in exponential notation?

Sravani S
Updated on 23-Jun-2020 08:43:16

975 Views

Use the toExponential() method to force a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.The following is the parameter −fractionDigits - An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.ExampleYou can try to run the following code to force a number to display in exponential function −           Javascript Method toExponential()                        var num=77.1234;          var ... Read More

How to convert Number to String in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 12:29:28

4K+ Views

This tutorial will teach us to convert the number to string in JavaScript. Changing the type of variable is called the type conversion of a variable. While coding, the programmer needs to deal with the different data types and might need to convert the variable's data type. Every programming language has different methods to convert one variable from one data type to another data type, and JavaScript also has some methods, which are explained below. Using the toString() Method Concatenating with an empty String Using the string() Constructor Using the toString() Method In JavaScript, the toString() method is ... Read More

Match any single character in the given set.

Krantik Chavan
Updated on 20-Jan-2020 11:00:37

113 Views

To match any single character in the given set with JavaScript RegExp, use the [aeiou] metacharacter.Example           JavaScript Regular Expression                        var myStr = "Welcome to our website!";          var reg = /[we]/g;          var match = myStr.match(reg);                    document.write(match);          

How to display the title of a document with JavaScript?

Shubham Vora
Updated on 31-Oct-2022 07:15:52

3K+ Views

In this tutorial, we will understand two approaches to display the document's title using JavaScript. Using document.title Property One of the most used methods in JavaScript to access an HTML document’s title is using a document.title property. In the following example, you will learn to get access to the title. After accessing the title in JavaScript, you can manipulate it and change the way it is displayed on a website. Syntax Here you can see how with the use onClick method, we can set the innerHTML of a paragraph within the document. The document.title is used to grab the title, ... Read More

Match any single character outside the given set.

Rama Giri
Updated on 20-Jan-2020 10:59:37

118 Views

To match any single character outside the given set with JavaScript RegExp, use the [^aeiou] metacharacter.Example           JavaScript Regular Expression                        var myStr = "Welcome!";          var reg = /[^lc]/g;          var match = myStr.match(reg);                   document.write(match);          

How to show the full URL of a document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:46:36

2K+ Views

We use the URL property of the document object to show the full URL of a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. It can be visualized as a hierarchy that is obtained after rendering the HTML structure of the web page. URL stands for Uniform Resource Locator. It contains the address of a resource on the internet. A Typical URL looks something like this− http://www.example.com/index.html It is ... Read More

Match any string with p at the beginning of it.

Smita Kapse
Updated on 23-Jun-2020 08:39:10

184 Views

To match any string with p at the beginning of it with JavaScript RegExp, use the ^p Quantifier −Example           JavaScript Regular Expression                        var myStr = "Welcome to our website. We Learners!";          var reg = /^We/g;          var match = myStr.match(reg);                    document.write(match);          

How to show the date and time the document was last modified with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:38:53

5K+ Views

We use the lastModified property of the document object to show the date and time the document was last modified with JavaScript. This command will provide the exact date and time of modification. The document object, part of the DOM, renders the whole HTML as a hierarchy of objects and their properties as well as stores different attributes of the webpage. document.lastModified It is a read-only property of the document object that returns a string containing the date and time, the document was last modified. The format looks something this: 07/29/2019 15:19:41 Note − The lastModified property is useful ... Read More

Match any string containing a sequence of at least two p's.

Abhinanda Shri
Updated on 20-May-2020 07:53:10

134 Views

To match any string containing a sequence of at least two p’s with JavaScript RegExp, use the p{2,} Quantifier.Example           JavaScript Regular Expression                        var myStr = "Welcome 1, 10, 100, 1000";          var reg = /\d{2,}/g;          var match = myStr.match(reg);          document.write(match);          

Advertisements