Articles on Trending Technologies

Technical articles with clear explanations and examples

Change value of input on form submit in JavaScript?

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

In JavaScript, you can change the value of an input field when a form is submitted using the document object. This is useful for modifying form data before submission or performing dynamic updates. Syntax document.formName.inputName.value = newValue; Basic Example Here's a form with a hidden input field that gets modified on submit: Change Input Value on Submit ...

Read More

Remove Seconds/ Milliseconds from Date and convert to ISO String?

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

In JavaScript, you can remove seconds and milliseconds from a Date object and convert it to an ISO string format. This is useful when you need precise time formatting without the seconds component. Getting the Current Date First, let's create a Date object with the current date and time: var currentDate = new Date(); console.log("The current date is: " + currentDate); The current date is: Sat Aug 01 2020 18:20:09 GMT+0530 (India Standard Time) Removing Seconds and Milliseconds Use the setSeconds() method to set both seconds and milliseconds to 0: ...

Read More

Replacing upperCase and LowerCase in a string - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 678 Views

We are required to write a JavaScript function that takes in a string and constructs a new string with all the uppercase characters converted to lowercase and all the lowercase characters converted to uppercase. Let's write the code for this function — Example Following is the code — const str = 'The Case OF tHis StrinG Will Be FLiPped'; const isUpperCase = char => char.charCodeAt(0) >= 65 && char.charCodeAt(0) char.charCodeAt(0) >= 97 && char.charCodeAt(0) { let newStr = ''; const margin = 32; ...

Read More

Remove elements from array using JavaScript filter - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 503 Views

Suppose, we have two arrays of literals like these − const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4]; const arr2 = [4, 56, 23]; We are required to write a JavaScript function that takes in these two arrays and filters the first to contain only those elements that are not present in the second array. And then return the filtered array to get the below output − const output = [7, 6, 3, 6, 3]; Method 1: Using filter() with indexOf() The filter() method creates ...

Read More

How to set the decoration of a text with JavaScript?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 1K+ Views

Use the textDecoration property in JavaScript to decorate text. This property allows you to add underlines, overlines, strikethrough effects, and more to any text element. Syntax element.style.textDecoration = "value"; Common textDecoration Values Value Effect underline Adds line below text overline Adds line above text line-through Strikes through text none Removes decoration Example: Basic Text Decoration Text Decoration Example This is demo text. ...

Read More

How to convert a binary NodeJS Buffer to JavaScript ArrayBuffer?

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

Converting a binary NodeJS Buffer to JavaScript ArrayBuffer is a common requirement when working with binary data across different JavaScript environments. There are multiple approaches to achieve this conversion. Method 1: Using buf.buffer Property (Direct Access) The simplest approach is to access the buf.buffer property directly. However, this creates a view of the underlying ArrayBuffer, not a copy. const buffer = Buffer.from([1, 2, 3, 4, 5]); console.log("Original Buffer:", buffer); // Direct access to underlying ArrayBuffer const arrayBuffer = buffer.buffer; console.log("ArrayBuffer byteLength:", arrayBuffer.byteLength); // Create Uint8Array view to inspect data const uint8View = new Uint8Array(arrayBuffer); ...

Read More

Move an HTML div in a curved path

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 439 Views

To move an HTML div in a curved path, you can use CSS animations, JavaScript, or HTML5 Canvas. JavaScript provides the most flexibility and browser compatibility for complex curved animations. CSS Transitions - Simple curved paths using cubic-bezier JavaScript (jQuery) - Custom curved animations with precise control HTML5 Canvas - Complex curved paths with mathematical precision We'll focus on JavaScript solutions using jQuery's animate() method and modern CSS transforms. jQuery animate() Method The animate() method performs custom animations by changing CSS properties over time. ...

Read More

Capitalize text with CSS

V Jyothi
V Jyothi
Updated on 15-Mar-2026 1K+ Views

To capitalize text in CSS, use the text-transform property with the capitalize value. This property transforms the first letter of each word to uppercase while keeping the rest lowercase. Syntax text-transform: capitalize; Basic Example Here's how to capitalize text using CSS: hello world from india Hello World From ...

Read More

Clearfix Bootstrap class

George John
George John
Updated on 15-Mar-2026 411 Views

The Bootstrap .clearfix class solves the common issue of parent containers collapsing when all child elements are floated. It ensures the parent container properly wraps around its floated children. What is Clearfix? When elements are floated using .pull-left or .pull-right, they are removed from the normal document flow. This can cause their parent container to have zero height, leading to layout problems. The .clearfix class forces the parent to expand and contain its floated children. Example Here's how to use the .clearfix class to properly contain floated elements: ...

Read More

Remove leading zeros in a JavaScript array?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 487 Views

To remove leading zeros from a JavaScript array, we use the filter() method with a closure function that tracks when the first non-zero element is encountered. Once a non-zero value is found, all subsequent elements (including zeros) are kept. Input Examples [10, 0, 12, 0, 0] [0, 0, 0, 0, 0, 0, 10, 12, 0] [12, 0, 0, 1, 0, 0] Example const removeLeadingZero = input => input.filter((lastValue => value => lastValue = lastValue || value) (false) ); console.log(removeLeadingZero([10, 0, 12, 0, 0])); console.log(removeLeadingZero([0, ...

Read More
Showing 16641–16650 of 61,297 articles
Advertisements