Found 444 Articles for Programming Scripts

How to work with document.images in JavaScript?

Arushi
Updated on 20-May-2020 11:00:53

462 Views

Use the document.images property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.images property in JavaScript.Live Demo           JavaScript Example               TutorialsPoint Tutorials                            var num = document.images.length;          document.write("How many images? "+num);          

How to return a random number between 1 and 200 with JavaScript?

Manikanth Mani
Updated on 24-Nov-2023 00:44:49

2K+ Views

To return a random number between 1 and 200, use the JavaScript's Math.random() and Math.floor() method. Example You can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200) + 1);          

How to return a random number between 0 and 199 with JavaScript?

Rama Giri
Updated on 20-May-2020 10:49:10

379 Views

To return a random number between 0 and 199, use the JavaScript Math.random() and Math.floor() method.ExampleYou can try to run the following code to return a random number in JavaScript.                    document.write(Math.floor(Math.random() * 200));          

How to convert Binary to Decimal in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 09:12:08

6K+ Views

In this tutorial, we will learn to convert the binary to decimal in JavaScript. The Binary number is used in digital electronics. It is a string of ‘0’ and ‘1’, representing the number with respect to base 2. Here are the different methods below to convert the binary number to decimal. Using the parseInt() Method In JavaScript, parseInt() method is useful to extract the number from the string. We can define the base for the number as a parameter in the parseInt() method. Syntax Users can follow the below syntax to use the parseInt() method to convert the binary to ... Read More

How to convert Decimal to Binary in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 11:51:59

21K+ Views

This tutorial will teach us to convert the decimal number to a binary number string. The binary number is the string of only 0 and 1. The computer doesn’t understand the high-level programming language, so we need to instruct the computer in a low-level language, represented as the binary string. Also, binary string is used in digital electronics. Here, we have three methods to convert the decimal number to a binary string. Using the toString() Method Using the right shift Operation Using the modulo Operator Using the toString() Method The toString() method is JavaScript built-in string method that ... Read More

How to work with document.embeds in JavaScript?

Jai Janardhan
Updated on 20-May-2020 10:51:40

171 Views

Use the document.embeds property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.embeds property in JavaScript.Live Demo           JavaScript Example                              var num = document.embeds.length;          document.write("How many embed tags: "+num);          

What is JavaScript Bitwise XOR (^) Operator?

Abhinaya
Updated on 20-May-2020 10:50:12

255 Views

If both the bits are different, then 1 is returned when Bitwise OR (|) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise XOR Operator.                    document.write("Bitwise XOR Operator");          // 7 = 00000000000000000000000000000111          // 1 = 00000000000000000000000000000001          document.write(7 ^ 1);          

What is JavaScript Bitwise NOT(~) Operator?

Anjana
Updated on 20-May-2020 09:36:34

243 Views

The Bitwise NOT (~) Operator performs NOT operation on the bits. You can try to run the following code to learn how to work with JavaScript Bitwise NOT Operator.Example                    document.write("Bitwise NOT Operator");          // 7 = 00000000000000000000000000000111          document.write(~7);          

What is JavaScript Bitwise OR (|) Operator?

Alankritha Ammu
Updated on 20-May-2020 09:35:39

195 Views

If one of the bits are 1, then 1 is returned when Bitwise OR (|) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise OR Operator.                    document.write("Bitwise OR Operator");          // 7 = 00000000000000000000000000000111          // 1 = 00000000000000000000000000000001          document.write(7 | 1);          

How to get the value of the type attribute of a link in JavaScript?

Paul Richard
Updated on 20-May-2020 09:35:04

534 Views

To get the value of the type attribute of a link in JavaScript, use the type property. The type attribute is used to tell that the document is html (text/html) or css (text/css), etc.ExampleYou can try to run the following code to get the value of the type attribute of a link.Live Demo           Qries                var myVal = document.getElementById("anchorid").type;          document.write("Value of type attribute: "+myVal);          

Advertisements