Found 10483 Articles for Web Development

How to convert Number to Boolean in JavaScript?

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

2K+ Views

This tutorial will teach us to convert a number to a Boolean in JavaScript. The variable of Boolean data type can contain only two values, true and false. When we convert the variables of any other data type to Boolean, it returns true for all non-falsy values and false for all falsy values. Let’s understand the falsy values. The JavaScript contains 6+ falsy values, and some of them are as below. Null 0 NaN False Undefined ‘ ’ From the above falsy values, we can say that for 0, we will get the false Boolean value and for ... Read More

How to show name/value pairs of cookies in a document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:34:32

850 Views

We use the cookie property of the document object to show the name/value pairs of cookies in 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. A server serves requests when a connection is set up and forgets everything about the user as soon as the connection is closed. This posed a nasty problem of bad user experience to the community. A cookie, resolves this problem by storing small but ... Read More

How to show the domain name of the server that loaded the document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:40:55

3K+ Views

We use the window.location.hostname property of the document object to show the domain name of the server that loaded the document using 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. Every resource or computer that is available on the internet has an address that is either IPV4 (192.88.99.255) or IPV6 (2001:db8:3333:4444:5555:6666:7777:8888). These addresses are good for computers but not for us. domain name system is a layer of abstraction over that organization ... Read More

How to find the number of anchors with JavaScript?

Abhishek
Updated on 31-Oct-2022 08:03:31

265 Views

In this tutorial, we will learn how to find the number of anchors used in an HTML document with JavaScript. Sometimes, During the development of a web page, the developer may need to add multiple links to the different buttons present on the webpage using multiple anchors for each button. In such a situation, if you want to find the number of anchor elements, you can use the anchors property. JavaScript allows us to use the anchors property to count the number of anchors ( elements) in an HTML document. Note − The document.anchors property is deprecated and no longer ... Read More

How to show the number of links in a document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:58:03

764 Views

We use the links property of the document object to show the number of links in 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. The links is a property of the document object that returns a list of all the hyperlinks present in the HTML document. A hyperlink may look something like this − "https://www.tutorialpoints.com/php" The links property of the document object lists all HTML elements having href ... Read More

How is NaN converted to Number in JavaScript?

Saurabh Jaiswal
Updated on 11-Aug-2022 14:35:24

10K+ Views

In this article, we will learn how to convert NaN to a Number. NaN in Javascript means Not a Number, whose type is Number but actually, it is not a number. To Convert, the NaN to a Number we use Multiple methods some of which are discussed below. Using the OR (||) operator Using the isNaN() method Using the ~~ operator Using Ternary Operator Using the OR (||) Operator The OR operator is represented by the || sign in JavaScript. To convert the NaN into a number we use the OR operator with NaN and any number and ... Read More

How to convert Boolean to String in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 11:46:24

3K+ Views

In this tutorial, we will learn to convert the Boolean to string in JavaScript. The problem is straightforward: sometimes programmers need to use the boolean true and false values as a string. So, there is a requirement to convert the Boolean to string. Here, we have various methods to convert the Boolean to a string variable. Using the toString() Method Using + and $ (template literal) Operator Using the ternary Operator Using the toString() method The toString() method is the JavaScript string library method, which is useful for converting the variables to the string data type. We can ... Read More

How to find the name of the first form in a document with JavaScript?

Abhishek
Updated on 31-Oct-2022 08:01:48

1K+ Views

In this tutorial, we will learn how to find the name of the first form in an HTML document. Sometimes, we use more than one form tags in the HTML document for different purposes. At that time, we can face difficulties in finding the specific element to add some more properties to it. In such conditions, we can use the forms property of the "document" interface to access all the elements present in the document individually as well as collectively Document.forms As we discussed above, the forms property is used to access all the forms present in the ... Read More

How to get the number of forms in a document with JavaScript?

Shubham Vora
Updated on 14-Sep-2022 08:47:27

1K+ Views

In this tutorial, we will learn how to get the number of forms in a document using JavaScript. Since different methods are used to create forms in an HTML document, it might get tricky to get the number of forms present. However, you can use some methods to count the forms created without the form tag. Using the length Property The most widely accepted method to create forms in HTML documents is using the tag. Some websites also use tags to create forms in the document. Hence, we will discuss the method to get the number of forms ... Read More

How to return the id of the first image in a document with JavaScript?

Kumar Varma
Updated on 23-Jun-2020 08:11:36

519 Views

To return the id of the first image, use the images property in JavaScript.ExampleYou can try to run the following code to return the id of the first image in a document −Live Demo                                            var val = document.images.length;          document.write("Number of images in the document: "+val);          document.write("The id of the first image: "+document.images[0].id);          

Advertisements