Articles on Trending Technologies

Technical articles with clear explanations and examples

How can I filter JSON data with multiple objects?

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

To filter JSON data with multiple objects, you can use the filter() method along with comparison operators. This allows you to extract specific objects based on criteria. Syntax array.filter(callback(element, index, array)) Example: Filter by Single Property const jsonObject = [ { studentId: 101, studentName: "David" }, { studentId: 102, ...

Read More

Checking semiprime numbers - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 459 Views

We are required to write a JavaScript function that takes in a number and determines if the provided number is a semiprime or not. What is a Semiprime? A semiprime number is a special type of composite number that is the product of exactly two prime numbers (not necessarily distinct). For example: 6 = 2 × 3 (product of two distinct primes) 15 = 3 × 5 (product of two distinct primes) 10 = 2 × 5 (product of two distinct primes) 4 = 2 × 2 (square of a prime) 9 = 3 × 3 ...

Read More

How to convert an array into JavaScript string?

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

An array is the most popular and adaptable data structure you might employ in your regular programming. Converting an array into a JavaScript String can be done using several predefined methods and techniques. Using the toString() Method Using the join() Method Using JSON.stringify() Method Using Type Coercion Using the toString() Method The toString() method is a built-in JavaScript function that converts array elements into a comma-separated string. It's the simplest way to convert an array to string format. ...

Read More

How can we assign a function to a variable in JavaScript?

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

In this tutorial, we will learn to assign a function to a variable in JavaScript. Functions are reusable code blocks that can be stored in variables as expressions. There are two main ways to achieve this: using anonymous functions and arrow functions. Most JavaScript programmers are familiar with named functions, which follow this syntax: function function_name() { // function body } However, when we want to assign a function to a variable as an expression, we have two different approaches: Creating Anonymous Functions ...

Read More

What is the usage of oninput event in JavaScript?

Sai Nath
Sai Nath
Updated on 15-Mar-2026 452 Views

The oninput event occurs whenever the value of an input element changes. Unlike onchange, which fires only when the element loses focus, oninput triggers immediately as the user types, making it ideal for real-time validation and live search functionality. Syntax // HTML attribute // JavaScript property element.oninput = function() { /* code */ }; // Event listener element.addEventListener('input', function() { /* code */ }); Basic Example oninput Example Type something below: ...

Read More

How to set an image as the list-item marker with JavaScript?

Monica Mona
Monica Mona
Updated on 15-Mar-2026 222 Views

To set an image as the marker in list items, use the listStyleImage property in JavaScript. This property allows you to replace default list markers (bullets or numbers) with custom images. Syntax element.style.listStyleImage = "url('image-path')"; Example The following example demonstrates how to set a custom image as the list-item marker: First Item Second Item Third Item ...

Read More

Websocket for binary transfer of data & decode with HTML5

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 932 Views

WebSockets can handle binary data transfer using base64 encoding/decoding. Modern browsers provide built-in methods window.btoa() for encoding and window.atob() for decoding base64 data. Base64 Encoding for Binary Transfer When transferring binary data through WebSockets, encode it as base64 on the client side before sending: // Create WebSocket connection const socket = new WebSocket('ws://localhost:8080'); // Convert ...

Read More

Remove elements from a Dictionary using Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 25K+ Views

In JavaScript, there are multiple ways to remove elements from dictionary-like structures. This depends on whether you're working with plain objects, custom dictionary classes, or ES6 Maps. Using delete Operator with Objects For plain JavaScript objects acting as dictionaries, use the delete operator: const dict = { key1: "value1", key2: "value2", key3: "value3" }; console.log("Before deletion:", dict); delete dict.key2; console.log("After deletion:", dict); console.log("key2 exists:", "key2" in dict); Before deletion: { key1: 'value1', key2: 'value2', key3: 'value3' } After ...

Read More

How to create animations using JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 365 Views

JavaScript animations are created by repeatedly changing CSS properties over time using functions like setInterval() or requestAnimationFrame(). This allows you to create smooth visual effects directly in the browser. Basic Animation Principles JavaScript animations work by: Selecting the element to animate Using a timer function to repeatedly update CSS properties Incrementing position, size, or other properties each frame Stopping the animation when the target is reached Example: Moving and Morphing Animation ...

Read More

Get value from div with JavaScript resulting undefined?

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

When trying to get the value from a div element using JavaScript, you might encounter undefined results if you use incorrect properties. The key is understanding the difference between innerHTML, textContent, and value. The Problem The most common mistake is using .value on div elements. The value property only works for form inputs like , , and . For div elements, use innerHTML or textContent. Using innerHTML innerHTML gets the HTML content inside the element, including any HTML tags: Get Div Value ...

Read More
Showing 17981–17990 of 61,297 articles
Advertisements