Programming Scripts Articles

Page 14 of 33

How to convert Binary to Decimal in JavaScript?

Shubham Vora
Shubham Vora
Updated on 08-Aug-2022 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 check whether a value is a safe integer or not in JavaScript?

Shubham Vora
Shubham Vora
Updated on 08-Aug-2022 685 Views

In this tutorial, we will learn to check whether a value is a safe integer or not in JavaScript. The simple definition of the safe integer in JavaScript is all numbers we can represent under the IEEE-754 double-precision number. It is the set of all numbers which lie between the -(2^53) to (2^53) exclusive, and we can represent it in the standard way. Here, we have different approaches to checking whether the number is a safe integer. Using the Number.IsSafeInteger() Method Using the if-else Conditional Statement Using the Number.isSafeInteger() Method In JavaScript, the isSafeInteger() method checks that type ...

Read More

How can I simplify the usage of Regular Expressions with JavaScript?

Shubham Vora
Shubham Vora
Updated on 14-Jul-2022 368 Views

In this tutorial, we will learn to simplify the use of regular expressions in JavaScript. Some of you have heard the regular expression word for the first time. So, it is not related to JavaScript but can be used in any programming language.The simple definition of the regular expression is that it is a sequence of the characters, also called Regex or RegExp. It can be a small or complex sequence.Let’s understand the need for regular expression by the example in the below section.Why should we use regular expressions?Suppose that you are developing the application and you need to take ...

Read More

How can I show image rollover with a mouse event in JavaScript?

Shubham Vora
Shubham Vora
Updated on 14-Jul-2022 10K+ Views

This tutorial will teach us to show image rollover with a mouse event in JavaScript. The meaning of the image rollover is to either change the image style or the whole image when the user rollovers the mouse on the image.To build an attractive user interface, developers often add image rollover features to the website and applications. Here, we will see to apply image rollover differently.Change the style of the image on mouse rolloverIn this method, to create the image rollover, we will use the onmouseover and onmouseout event of JavaScript. When users take the mouse pointer on the image, ...

Read More

HTML5 Canvas distorted

Chandu yadav
Chandu yadav
Updated on 16-Dec-2021 733 Views

If the canvas looks distorted, then try to change the height and width −The default height and width of the canvas in HTML5 is of 2/1 ratio −width = 300 height = 150ExampleLet us see an example −                    #mycanvas{border:1px solid red;}                         Output

Read More

How to draw an oval in HTML5 canvas?

Arjun Thakur
Arjun Thakur
Updated on 16-Dec-2021 1K+ Views

You can try to run the following code to draw an oval in HTML5 canvas −Example                                  // canvas          var c = document.getElementById('newCanvas');          var context = c.getContext('2d');          var cX = 0;          var cY = 0;          var radius = 40;                    context.save();          context.translate(c.width / 2, c.height / 2);          context.scale(2, 1);          context.beginPath();          context.arc(cX, cY, radius, 0, 2 * Math.PI, false);          context.restore();          context.fillStyle = '#000000';          context.fill();          context.lineWidth = 2;          context.strokeStyle = 'yellow';          context.stroke();           Output

Read More

Explain how to remove Leading Zeroes from a String in Java

Venkata Sai
Venkata Sai
Updated on 29-Jun-2020 3K+ Views

Whenever you read an integer value into a String, you can remove leading zeroes of it using StringBuffer class, using regular expressions or, by converting the given String to character array.Converting to character arrayFollowing Java program reads an integer value from the user into a String and removes the leading zeroes from it by converting the given String into Character array.Exampleimport java.util.Scanner; public class LeadingZeroes {    public static String removeLeadingZeroes(String num){       int i=0;       char charArray[] = num.toCharArray();       for( ; i

Read More

Passing mouse clicks through an overlaying HTML element <div>

Ankith Reddy
Ankith Reddy
Updated on 25-Jun-2020 1K+ Views

Retrieve the mouse coordinates in the click event. Now, retrieve the element by hiding your overlay, and use the following. After that, redisplay the overlay −document.elementFromPoint(x, y)You can also use the following CSS −div {    pointer-events:none; }

Read More

Render ASP.NET TextBox as HTML5 Input type “Number”

karthikeya Boyini
karthikeya Boyini
Updated on 25-Jun-2020 1K+ Views

To render ASP.NET TextBox as HTML5 input type “Number”, set type="number" directly on the textbox.Let us see an example of ASP.NET TextBox −You can also use the following dynamically created the control −TextBox tb = new TextBox(); tb.Attributes.Add("Type", "number");

Read More

The correct way to work with HTML5 checkbox

Giri Raju
Giri Raju
Updated on 24-Jun-2020 249 Views

The following is the correct way −ExampleHere is an example −           Checkbox Control                         Maths           Physics            

Read More
Showing 131–140 of 328 articles
« Prev 1 12 13 14 15 16 33 Next »
Advertisements