Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 285 of 534
How to compare two numbers in JavaScript?
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 MoreHow to block a website in your web browsers (Chrome and Internet Explorer)
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 MoreWebGL: Prevent color buffer from being cleared in HTML5
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 MoreHow to remove leading zeros from a number in JavaScript?
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 MoreHow to refresh a page in Firefox?
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 MoreDraw a circle filled with random color squares on HTML5 canvas
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 MoreHow to format a rounded number to N decimals using JavaScript?
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 MoreHow to define a measurement in screen pixels with CSS?
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 MoreHow to change Firefox Browser theme?
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 MoreHow to format hexadecimal Number in JavaScript?
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