Javascript Articles

Page 285 of 534

How to compare two numbers in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 19K+ Views

In this tutorial, we will learn to compare two numbers in JavaScript. Whether you're a competitive coder or application developer, you'll often need to compare numbers and perform operations based on the comparison results. Many programmers think we can only compare numbers using equality operators, but we can also use less than () operators for comprehensive comparisons. Using the Strict Equality Operator (===) JavaScript has two equality operators: loose equality (==) and strict equality (===). The strict equality operator compares both value and data type, making it more reliable for number comparisons. Syntax let ...

Read More

How to block a website in your web browsers (Chrome and Internet Explorer)

Johar Ali
Johar Ali
Updated on 15-Mar-2026 418 Views

To block a website on web browsers like Google Chrome, Firefox, and Internet Explorer in a Windows system, you can modify the system's hosts file. This method works by redirecting website requests to your local machine. How It Works The hosts file acts as a local DNS lookup table. When you add an entry like 127.0.0.1 website.com, your system redirects that website to your local machine (127.0.0.1), effectively blocking access. Step-by-Step Instructions Step 1: Open Notepad as an administrator by right-clicking on Notepad and selecting Run as Administrator. Step 2: In Notepad, click File → ...

Read More

WebGL: Prevent color buffer from being cleared in HTML5

Samual Sam
Samual Sam
Updated on 15-Mar-2026 236 Views

In WebGL, the color buffer is automatically cleared at the beginning of each frame by default. This can be problematic when you want to preserve previous drawings for effects like trails or persistent graphics. The Problem Even when you manually clear the color buffer using clearColor() and clear(), the WebGL context automatically clears the drawing buffer before the next frame: // Manual clearing - but buffer still gets cleared automatically gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); This automatic clearing happens at the beginning of the next draw cycle, making it impossible to build up graphics ...

Read More

How to remove leading zeros from a number in JavaScript?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 21K+ Views

In this tutorial, we will explore how we can remove leading zeroes from any number in JavaScript. JavaScript removes leading zeroes from an integer variable automatically, but this is not the case when we consider strings in JavaScript. It is possible that a string in JavaScript which represents a numerical value may contain leading zeroes. These leading zeroes may cause problems when we try to perform any operation on the numerical value the string represents. This is why we will explore the ways by which we can remove the leading zeroes from a number, expressed as a string in ...

Read More

How to refresh a page in Firefox?

Amit Sharma
Amit Sharma
Updated on 15-Mar-2026 619 Views

To refresh a page in a web browser like Firefox means reloading the page. It's quite easy to refresh a page using several different methods. Method 1: Using the Refresh Button Open the web page which you want to refresh. The refresh button is located on the top right corner of the Firefox web browser - it's the circular arrow icon. https://example.com ...

Read More

Draw a circle filled with random color squares on HTML5 canvas

Sravani S
Sravani S
Updated on 15-Mar-2026 1K+ Views

When we need to fill a circle with 1x1 pixels, all with different colors in a browser, we can use HTML5 Canvas with a layered approach. Approach Drawing all pixels with random colors in a 200x200 grid on a canvas Changing composite mode to clip content Drawing circle on top to mask the random pixels Example Here's how to create a circle filled with colorful random squares: Random Color Circle ...

Read More

How to format a rounded number to N decimals using JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 524 Views

Use the toFixed() method to format a rounded number to N decimals. The toFixed() method formats a number with a specific number of digits to the right of the decimal point and returns a string representation. Syntax number.toFixed(digits) Parameters digits (optional): An integer specifying the number of digits after the decimal point. Must be in the range 0-100. Default is 0. Return Value Returns a string representation of the number with the specified number of decimal places. Example Here's how to format numbers to different decimal places: ...

Read More

How to define a measurement in screen pixels with CSS?

mkotla
mkotla
Updated on 15-Mar-2026 230 Views

To define a measurement in screen pixels with CSS, use the px unit. The pixel (px) is an absolute unit that represents a single dot on the screen and provides precise control over element sizing and positioning. Syntax property: value px; Example: Using Pixels for Positioning and Sizing .pixel-example { position: relative; left: 90px; ...

Read More

How to change Firefox Browser theme?

Johar Ali
Johar Ali
Updated on 15-Mar-2026 444 Views

Firefox web browser is widely used and loved by many users around the world. You can easily change the Firefox Browser theme to customize its appearance and make it look more awesome. Let's see how to reach the Firefox theme section and change the theme: Step 1: Open Firefox Menu Go to the Firefox browser menu by clicking the three horizontal lines (hamburger menu) in the top-right corner. From the dropdown menu, click on "Add-ons and themes": ...

Read More

How to format hexadecimal Number in JavaScript?

Giri Raju
Giri Raju
Updated on 15-Mar-2026 2K+ Views

JavaScript provides several methods to format hexadecimal numbers. The most common approach is using toString(16) to convert numbers to hexadecimal format, then applying padding and formatting as needed. Basic Hexadecimal Conversion The toString(16) method converts a number to its hexadecimal representation: let num = 255; let hex = num.toString(16); document.write("Number: " + num + ""); document.write("Hexadecimal: ...

Read More
Showing 2841–2850 of 5,340 articles
« Prev 1 283 284 285 286 287 534 Next »
Advertisements