Articles on Trending Technologies

Technical articles with clear explanations and examples

JavaScript JSON Arrays

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 341 Views

JSON arrays are ordered lists of values enclosed in square brackets. In JavaScript, you can access and manipulate JSON arrays just like regular JavaScript arrays. Syntax { "arrayName": ["value1", "value2", "value3"] } Basic JSON Array Structure Here's how a JSON object with an array property looks: JSON Array Example let obj = { ...

Read More

Circle coordinates to array in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 529 Views

In JavaScript, you can generate circle coordinates by using trigonometric functions to calculate points around a circle's circumference. This is useful for animations, graphics, and positioning elements in circular patterns. How Circle Coordinates Work A circle's coordinates are calculated using the parametric equations: X coordinate: centerX + radius × cos(angle) Y coordinate: centerY + radius × sin(angle) By dividing the circle into equal steps and calculating coordinates at each angle, we can create an array of points around the circle. Example ...

Read More

Reverse a number in JavaScript

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

Our aim is to write a JavaScript function that takes in a number and returns its reversed number. For example, reverse of 678 is: 876 There are multiple approaches to reverse a number in JavaScript. Let's explore the most common methods. Method 1: Using String Conversion The most straightforward approach converts the number to a string, reverses it, and converts back to a number: const num = 124323; const reverse = (num) => parseInt(String(num) .split("") .reverse() .join(""), 10); console.log(reverse(num)); ...

Read More

Update array of objects with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 506 Views

In JavaScript, you can update an array of objects by modifying existing objects or adding new ones. This is commonly done using methods like push(), splice(), or array methods like map() and find(). Let's say we have the following array of objects: var studentDetails = [ { firstName: "John", listOfSubject: ['MySQL', 'MongoDB']}, {firstName: "David", listOfSubject: ['Java', 'C']} ]; console.log("Initial array:", studentDetails); Initial array: [ { firstName: 'John', listOfSubject: [ 'MySQL', 'MongoDB' ] }, { firstName: 'David', listOfSubject: [ 'Java', 'C' ] } ] ...

Read More

Squared sum of n odd numbers - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 346 Views

We are required to write a JavaScript function that takes in a Number, say n, and finds the sum of the square of first n odd natural Numbers. For example, if the input number is 3, we need to find the first 3 odd numbers (1, 3, 5) and calculate the sum of their squares: 1² + 3² + 5² = 1 + 9 + 25 = 35 Understanding the Pattern The first n odd natural numbers follow the pattern: 1, 3, 5, 7, 9... The formula for the i-th odd number is (2 * i) - 1. Example const num = 3; const squaredSum = num => { let sum = 0; for(let i = 1; i

Read More

How do I replace a character at a particular index in JavaScript?

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

JavaScript strings are immutable, meaning you can't directly replace a character at a specific index like in other languages. However, we can use several approaches to create a new string with the character replaced at the desired position. In this tutorial, we'll explore two effective methods to replace a character at a particular index in a JavaScript string. Replace Character by Converting String to Array Using String Slicing with substring() Replace Character by Converting String to Array This method converts the string to an array, modifies the character ...

Read More

How to set line breaking rules for non-CJK scripts in JavaScript?

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

The word-break CSS property controls how words break when text overflows its container. For non-CJK (Chinese, Japanese, Korean) scripts like English, you can set different line breaking behaviors using JavaScript. Syntax element.style.wordBreak = "value"; word-break Property Values Value Description Use Case normal Default breaking rules Standard text flow break-all Break anywhere, even mid-word Prevent overflow in narrow containers keep-all Don't break CJK text Preserve CJK word integrity Example: Interactive Word Breaking ...

Read More

What exactly is the pushState state object in HTML?

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 281 Views

The pushState state object is a JavaScript object that stores data associated with a specific history entry in the browser's history stack. It allows you to save information that can be retrieved when the user navigates back or forward through history. Syntax history.pushState(state, title, url); Parameters state - An object containing data to associate with the history entry title - The title for the new history entry (often ignored by browsers) url - The new URL to display in the address bar Example: Creating History Entries with State ...

Read More

Detect compatibility of the new HTML5 tag with jQuery.

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 205 Views

Use the following to check the compatibility of the HTML5 tag with jQuery: Method: Testing Default Styling This method creates a element and checks if the browser applies the default yellow background color, indicating HTML5 support. function checkMarkTagSupport() { var $myEL = $(''); ...

Read More

Usage of -moz-opacity property with CSS

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 863 Views

The -moz-opacity property was a Mozilla-specific CSS property used to set the opacity of HTML elements, including images. This property created transparent effects in older Firefox browsers before the standard opacity property was widely supported. Browser-Specific Opacity Properties Different browsers historically required different approaches for opacity: Mozilla Firefox: -moz-opacity Internet Explorer: filter: alpha(opacity=x) Modern browsers: opacity (standard) Syntax /* Legacy Mozilla syntax */ -moz-opacity: value; /* IE filter syntax */ filter: alpha(opacity=value); /* Modern standard syntax */ opacity: value; The value ranges from 0 (completely transparent) to 1 ...

Read More
Showing 16881–16890 of 61,297 articles
Advertisements