Articles on Trending Technologies

Technical articles with clear explanations and examples

Merge two arrays with alternating Values in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 943 Views

Merging two arrays with alternating values means creating a new array that picks elements from each array in turn: first element from array1, first element from array2, second element from array1, and so on. Using While Loop with Index Tracking This approach uses separate counters to track positions in each array and alternates between them: const arr1 = [34, 21, 2, 56, 17]; const arr2 = [12, 86, 1, 54, 28]; let run = 0, first = 0, second = 0; const newArr = []; while(run < arr1.length + arr2.length){ if(first ...

Read More

Recursive product of summed digits JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 241 Views

We need to create a function that takes multiple numbers as arguments, adds them together, then repeatedly multiplies the digits of the result until we get a single digit. Problem Breakdown For example, with arguments 16, 34, 42: 16 + 34 + 42 = 92 Then multiply digits until single digit: 9 × 2 = 18 1 × 8 = 8 (final result) Solution Approach We'll break this into two helper functions: produce() - calculates the product of digits in a number using ...

Read More

How do I check whether a checkbox is checked in jQuery?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 395 Views

To check whether a checkbox is checked in jQuery, you can use several methods. The most common approaches are using the .is(':checked') method, the .prop('checked') method, or implementing toggle functionality. Method 1: Using .is(':checked') The .is(':checked') method returns a boolean value indicating whether the checkbox is checked: Checkbox Check Example Check me Check Status ...

Read More

How to work with document.head in JavaScript?

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

In this tutorial, let us discuss how to work with the document's head in JavaScript. The document.head property is a DOM Level 3 read-only feature that returns the element of the current document. This property provides access to metadata elements like title, meta tags, stylesheets, and scripts. The head tag contains document metadata including title, keywords, description, and stylesheets. Every HTML document should have a head section, though the opening and closing tags are optional in HTML. Syntax let headElement = document.head; Return Value The document.head property returns the HTML ...

Read More

How to set the page-break behavior inside an element with JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 3K+ Views

Use the pageBreakInside property in JavaScript to control page-break behavior inside an element when printing. This property determines whether a page break should occur within an element's content. Note − The changes are only visible when printing or viewing the print preview. Syntax element.style.pageBreakInside = "value"; Property Values Value Description auto Allow page breaks inside the element (default) avoid Avoid page breaks inside the element if possible inherit Inherit from parent element Example: Setting Page Break Behavior Here's how to control ...

Read More

Playing MP4 video in WebView using HTML5 in Android

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 1K+ Views

To play MP4 videos in Android WebView using HTML5, you need to enable JavaScript, DOM storage, and configure proper video handling. This requires both Android configuration and HTML5 video implementation. Android WebView Configuration First, configure your WebView settings to support HTML5 video playback: // Enable JavaScript and DOM storage WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setAllowContentAccess(true); webSettings.setMediaPlaybackRequiresUserGesture(false); // Enable hardware acceleration webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); HTML5 Video Implementation Create an HTML page with HTML5 video element to play MP4 files: ...

Read More

How to convert a string to a floating point number in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 15-Mar-2026 2K+ Views

In JavaScript, converting a string to a floating point number is a common task that can be accomplished through several methods. This article explores three effective approaches to achieve this conversion. Using the parseFloat() Method The parseFloat() function is the most direct way to convert a string to a floating point number. It parses a string and returns the first number found, including decimal values. Syntax parseFloat(string) Note: If the first character cannot be converted to a number, parseFloat() returns NaN. Example: Basic parseFloat() Usage ...

Read More

What is the use of sinon.js?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 618 Views

SinonJS provides standalone test spies, stubs and mocks for JavaScript unit testing. It helps create fake objects and functions to isolate and test code in controlled environments. What is SinonJS? SinonJS is a testing library that provides utilities for creating test doubles. These help you test code in isolation by replacing dependencies with controlled fake implementations. Core Features SinonJS offers three main types of test doubles: Spies — Track function calls without changing behavior. They record how functions are called. Stubs — Replace functions with controlled implementations. You can define what they return or ...

Read More

How to invoke a function as a function and method?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 180 Views

In JavaScript, functions can be invoked in different ways. When called directly, it's function invocation. When called as a property of an object, it's method invocation. Function vs Method Invocation Function invocation: Calling a function directly by its name. Method invocation: Calling a function that belongs to an object using dot notation. Example Function and Method Invocation body { ...

Read More

Dot notation in JavaScript

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

Dot notation is the most common way to access object properties in JavaScript. It uses a dot (.) between the object name and property name to retrieve or set values. Syntax objectName.propertyName Basic Example Dot Notation Example Student Information Show Student Details function Student(name, age, standard) { ...

Read More
Showing 17701–17710 of 61,297 articles
Advertisements