Articles on Trending Technologies

Technical articles with clear explanations and examples

HTML5 Canvas Degree Symbol

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 526 Views

The HTML5 Canvas API allows you to display special characters like the degree symbol (°) in text. You can use HTML entities or Unicode characters to render the degree symbol on canvas. Using HTML Entity for Degree Symbol The most common approach is using the HTML entity ° which renders as the degree symbol (°). body { ...

Read More

How to resize a navigation bar on scroll with CSS and JavaScript?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 3K+ Views

In this article, we will discuss how to resize a navigation bar on scroll with the help of CSS and JavaScript. A navigation bar contains the list of elements present in your website, including the links to navigate through the website. It's usually the first pit-stop for users visiting the website who seek guidance to walk through the website. Resizing is achieved by dynamically changing the padding and font sizes of the navigation bar elements using JavaScript when the user scrolls. This creates a smooth transition effect that makes the navbar smaller as the user scrolls down. ...

Read More

Undeclared vs Undefined? In JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

In JavaScript, undeclared and undefined are two different concepts that developers often confuse. Understanding the distinction is crucial for debugging and writing reliable code. Key Differences Undeclared occurs when you try to access a variable that hasn't been declared using var, let, or const. This results in a ReferenceError. Undefined occurs when a variable has been declared but hasn't been assigned a value. The variable exists but contains the special value undefined. Example: Undefined Variable Undefined Variable ...

Read More

How to generate array of n equidistant points along a line segment of length x with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 407 Views

To generate an array of n equidistant points along a line segment of length x, we divide the segment into equal intervals and calculate each point's position based on its proportional distance. Syntax for (let i = 0; i < n; i++) { let ratio = (i + 1) / (n + 1); let point = ratio * segmentLength; // Add point to array } Example function generateEquidistantPoints(n, segmentLength) { const points = []; ...

Read More

Finding average word length of sentences - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 531 Views

We are required to write a JavaScript function that takes in a string of words joined by whitespaces. The function should calculate and return the average length of all the words present in the string rounded to two decimal places. Understanding the Problem To find the average word length, we need to: Split the string into individual words Calculate the total length of all words (excluding spaces) Divide by the number of words Round the result to two decimal places Example Following ...

Read More

What is the best way to initialize a JavaScript Date to midnight?

V Jyothi
V Jyothi
Updated on 15-Mar-2026 582 Views

To initialize a JavaScript Date to midnight, you need to set the time components (hours, minutes, seconds, and milliseconds) to zero using the setHours() method. Syntax date.setHours(hours, minutes, seconds, milliseconds) For midnight, use: date.setHours(0, 0, 0, 0) Example: Setting Current Date to Midnight var dt = new Date(); console.log("Original date:", dt.toString()); dt.setHours(0, 0, 0, 0); ...

Read More

How to Debug JavaScript on iPad?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 779 Views

To debug JavaScript on iPad, you need to use Safari's Web Inspector feature along with a Mac computer. This process involves enabling developer tools on both devices and establishing a connection between them. Prerequisites Before starting, ensure you have: An iPad with Safari browser A Mac computer with Safari installed A USB cable to connect iPad to Mac The website or web app you want to debug Step 1: Enable Web Inspector on iPad First, you need to enable the Web Inspector feature in your iPad's Safari settings: Open the Settings app ...

Read More

What is the role of ctrlKey Mouse Event in JavaScript?

Govinda Sai
Govinda Sai
Updated on 15-Mar-2026 301 Views

The ctrlKey mouse event property is a boolean value that indicates whether the CTRL key was pressed when a mouse event occurred. This property is available on all mouse events like click, mousedown, mouseup, etc. Syntax event.ctrlKey Return Value true - if the CTRL key was pressed during the mouse event false - if the CTRL key was not pressed during the mouse event Example The following example demonstrates how to detect if the CTRL key is pressed when clicking on an element: ...

Read More

Creating content with HTML5 Canvas much more complicated than authoring with Flash

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

Flash provided amazing GUI tools and visual features for animations, allowing developers to build multimedia content within a self-contained platform. However, Flash required browser plugins and had security concerns that led to its deprecation. HTML5's element offers a modern, plugin-free alternative for creating graphics and animations using JavaScript. It provides direct access to a drawing context where you can render shapes, images, and complex animations programmatically. Basic Canvas Setup A canvas element requires only width and height attributes, plus standard HTML attributes: Drawing with Canvas Unlike Flash's visual timeline, Canvas ...

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
Showing 18241–18250 of 61,297 articles
Advertisements