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
Articles on Trending Technologies
Technical articles with clear explanations and examples
HTML5 Canvas Degree Symbol
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 MoreHow to resize a navigation bar on scroll with CSS and JavaScript?
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 MoreUndeclared vs Undefined? In JavaScript
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 MoreHow to generate array of n equidistant points along a line segment of length x with JavaScript?
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 MoreFinding average word length of sentences - JavaScript
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 MoreWhat is the best way to initialize a JavaScript Date to midnight?
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 MoreHow to Debug JavaScript on iPad?
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 MoreWhat is the role of ctrlKey Mouse Event in JavaScript?
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 MoreCreating content with HTML5 Canvas much more complicated than authoring with Flash
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 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 More