Articles on Trending Technologies

Technical articles with clear explanations and examples

Usage of background property in CSS

Sreemaha
Sreemaha
Updated on 15-Mar-2026 129 Views

The background property in CSS is a shorthand property that allows you to set multiple background-related properties in a single declaration. It can include background color, image, position, size, repeat behavior, and attachment. Syntax background: [color] [image] [repeat] [attachment] [position] / [size]; Individual Background Properties The background shorthand can include any combination of these properties: background-color - Sets the background color background-image - Sets the background image background-repeat - Controls image repetition background-attachment - Controls scrolling ...

Read More

TypedArray.BYTES_PER_ELEMENT property in JavaScript

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

The BYTES_PER_ELEMENT property of TypedArrays represents the number of bytes each element occupies in memory. This static property helps determine the memory size of different typed array types. Syntax TypedArray.BYTES_PER_ELEMENT Where TypedArray can be any typed array constructor like Int8Array, Float32Array, etc. Example: Different TypedArray Sizes JavaScript Example var sizeOfFloat32Array = Float32Array.BYTES_PER_ELEMENT; document.write("Size of Float32Array element: " + sizeOfFloat32Array + " bytes"); ...

Read More

Sum is to be calculated for the numbers in between the array's max and min value JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 214 Views

We need to write a function called sumBetween() that takes an array of two elements and returns the sum of all integers between those values, including both endpoints. For example: [4, 7] = 4+5+6+7 = 22 [10, 6] = 10+9+8+7+6 = 40 Understanding the Problem The function should work regardless of which number is larger. Whether we pass [4, 7] or [7, 4], we need to sum all integers from 4 to 7 inclusive. Solution Using Mathematical Formula We can use the mathematical formula for sum of consecutive integers: sum from 1 ...

Read More

How to convert string type value to array type in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 452 Views

Converting strings to arrays in JavaScript can be done using different methods depending on the string format. Here are the most common approaches. Using JSON.parse() for JSON Strings When you have a JSON-formatted string, use JSON.parse() to convert it to an array: var customerDetails = '[{"name": "John", "countryName": "US"}, {"name": "David", "countryName": "AUS"}, {"name": "Bob", "countryName": "UK"}]'; console.log("Original string:", customerDetails); console.log("Type:", typeof customerDetails); var convertStringToArray = JSON.parse(customerDetails); console.log("After converting to array:"); console.log(convertStringToArray); console.log("Type:", typeof convertStringToArray); Original string: [{"name": "John", "countryName": "US"}, {"name": "David", "countryName": "AUS"}, {"name": "Bob", "countryName": "UK"}] Type: string ...

Read More

How to use JavaScript to set cookies for homepage only?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 380 Views

Setting cookies for a specific page like the homepage requires checking the current page URL before creating the cookie. This ensures the cookie is only set when users are on the designated homepage. Understanding the Approach To restrict cookie setting to the homepage only, we need to: Get the current page URL using window.location.pathname Check if the current page matches our homepage criteria Set the cookie only if the condition is met Example: Setting Cookies for Homepage Only ...

Read More

How can I force clients to refresh JavaScript files?

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

When you update JavaScript files on your server, browsers may still load the old cached version instead of your new code. This tutorial shows you how to force browsers to reload updated JavaScript files automatically. The problem occurs because browsers cache JavaScript files locally for faster loading. When you deploy new code, browsers continue serving the old cached files instead of fetching updated ones from the server. This causes users to see outdated functionality even after you've deployed new features or fixes. Understanding Browser Caching When users visit your application, browsers store CSS and JavaScript files in ...

Read More

What is the usage of in operator in JavaScript?

Arushi
Arushi
Updated on 15-Mar-2026 200 Views

The in operator is used in JavaScript to check whether a property exists in an object or not. It returns true if the property is found, and false otherwise. Syntax propertyName in object Basic Example Here's how to use the in operator to check for properties in objects: var emp = {name: "Amit", subject: "Java"}; document.write("name" in emp); document.write(""); document.write("subject" in emp); document.write(""); document.write("age" in emp); document.write(""); document.write("MAX_VALUE" in Number); true true false true Checking Array Indices The in ...

Read More

How to set the shape of the border of the top-left corner with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 405 Views

In this tutorial, we will learn to set the radius of the top-left corner of the border using JavaScript DOM. To set the shape of the border of the top-left corner in JavaScript, use the borderTopLeftRadius property. Set the border radius using this property. We apply borders on a webpage many times. Generally, it is used to display the importance of an element or a difference between the sections. We can create a table in a webpage by using HTML. It is a simple table that does not attract the user. So, we use CSS to design the table ...

Read More

Is there a way to add/remove several classes in one single instruction with classList in HTML and JavaScript?

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

The classList property returns the class names of an element as a DOMTokenList object. While it's read-only, you can modify it using methods like add() and remove(). The classList property automatically prevents duplicate classes from being added. You can add or remove multiple classes in a single instruction using several approaches. Using Multiple Parameters (ES6+) Modern browsers support passing multiple class names as separate parameters: Content const element = document.getElementById('myDiv'); // Add multiple classes element.classList.add('active', 'highlighted', 'primary'); console.log(element.className); // Remove multiple classes element.classList.remove('active', 'highlighted'); console.log(element.className); container active ...

Read More

Set heights and widths of forms with Bootstrap

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 2K+ Views

Bootstrap provides classes to control form element heights and widths. Use .input-lg, .input-sm for height sizing, and grid classes like .col-lg-* for width control. Height Sizing Classes Bootstrap offers three height sizes for form controls: .input-lg - Large height input Default - Standard height (no class needed) .input-sm - Small height input Width Control with Grid System Use Bootstrap's grid classes to control form element widths. Wrap inputs in .row and use column classes like .col-lg-2, .col-lg-3, etc. Example Here's how to implement different form sizes: ...

Read More
Showing 18711–18720 of 61,297 articles
Advertisements