Articles on Trending Technologies

Technical articles with clear explanations and examples

Example of createSignalingChannel() in HTML5

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

WebRTC enables peer-to-peer communication between browsers, requiring signaling for network information, session control, and media exchange. Developers can implement signaling using various protocols like SIP, XMPP, or custom two-way communication channels. What is createSignalingChannel()? The createSignalingChannel() function establishes a communication channel between peers to exchange connection information before direct peer-to-peer communication begins. This is essential for WebRTC setup. Complete Example var signalingChannel = createSignalingChannel(); var pc; var configuration = { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] }; // run start(true) to initiate a call function start(isCaller) { ...

Read More

Indexed collections in JavaScript

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

JavaScript provides indexed collections that allow you to store and access elements using numeric indices. Arrays are the most common indexed collection, where each element has a position (index) starting from 0. What are Indexed Collections? Indexed collections are data structures where elements are accessed using numerical indices. In JavaScript, arrays are the primary indexed collection type, allowing you to store multiple values and retrieve them using their position. Basic Array Creation and Access Indexed Collections ...

Read More

Remove number properties from an object JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 359 Views

In JavaScript, we often need to filter object properties based on their data types. This article demonstrates how to remove properties of a specific type from an object using a reusable function. Problem Statement Given an object with mixed property types (numbers, strings, booleans, objects), we need to create a function that removes all properties of a specified data type. If no type is specified, it should default to removing number properties. Solution We'll create a function called shedData that iterates through object properties and deletes those matching the specified type: const obj = ...

Read More

Converting string to MORSE code in JavaScript

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

What is Morse Code? Morse code is a method used in telecommunications to encode text characters as standardized sequences of two different signal durations, called dots and dashes. Each letter of the alphabet has a unique pattern of dots (.) and dashes (-). To convert a string to Morse code in JavaScript, we need an object that maps all alphabets to their Morse code equivalents, then iterate through the input string to build the encoded result. Morse Code Map First, let's create an object containing all alphabet-to-Morse mappings: const morseCode = { ...

Read More

How to match strings that aren't entirely digits in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 160 Views

In JavaScript, you can use regular expressions to match strings that contain non-digit characters. This is useful when parsing complex data strings where you need to identify values that aren't purely numeric. Problem Statement Consider this complex string containing various data types: studentId:"100001",studentName:"John Smith",isTopper:true,uniqueId:10001J-10001,marks:78,newId:"4678" We want to extract values that contain characters other than digits, excluding boolean values and null. Using Regular Expression The following regular expression matches strings that aren't entirely digits: var regularExpression = /(?

Read More

Why in JavaScript, "if ('0' == false)" is equal to false whereas it gives true in "if(0)" statement?

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

JavaScript's comparison behavior can be confusing when mixing different data types. Let's examine why '0' == false returns true while if(0) evaluates to false. Understanding '0' == false When using the loose equality operator ==, JavaScript performs type coercion following specific rules: console.log('0' == false); // true console.log(typeof '0'); // "string" console.log(typeof false); // "boolean" true string boolean The comparison follows this rule: If Type(y) is Boolean, return the result of the comparison x == ToNumber(y) Here's what happens step by step: ...

Read More

How to write JavaScript Regular Expression for multiple matches?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 366 Views

To find multiple matches in JavaScript, use the global flag (g) with regular expressions. The exec() method can be called repeatedly to find all matches in a string. Syntax let regex = /pattern/g; let matches; while ((matches = regex.exec(string)) !== null) { // Process each match } Example: Extracting URL Parameters This example extracts all demo parameters from a URL query string: var url = 'https://www.example.com/new.html?ui=7&demo=one&demo=two&demo=three'; var a = document.createElement('a'); a.href = url; var demoRegex = /(?:^|[&;])demo=([^&;]+)/g; var matches; var demo = []; ...

Read More

How to return a number of bits used to display one color on a window screen in JavaScript?

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 360 Views

In this tutorial, we will explore how we can find out the number of bits that are used to display a single color on the screen of our device using JavaScript. JavaScript has many inbuilt functions that allow us to get information about the various properties of the display screen. We'll be using one such function to accomplish the task mentioned above. As discussed in the previous section, we want to find out the exact number of bits that are used to display a particular color on the user's display screen by using JavaScript. Before we can access the ...

Read More

How to set the minimum number of lines for an element that must be visible at the top of a page in JavaScript?

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

The orphans CSS property sets the minimum number of lines in a block container that must be shown at the top of a page when a page break occurs. In JavaScript, you can control this property through the DOM to manage print layout behavior. Syntax // Get the orphans value var orphansValue = element.style.orphans; // Set the orphans value element.style.orphans = "number|initial|inherit"; Parameters Value Description number Minimum number of lines (default is 2) initial Sets to default value inherit Inherits from parent element ...

Read More

Do any browsers yet support HTML5's checkValidity() method?

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

Yes, modern browsers widely support HTML5's checkValidity() method. This method validates form elements against their HTML5 constraints and returns true if valid, false otherwise. Browser Support The checkValidity() method is supported in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. It's been widely supported since around 2012-2013. Syntax element.checkValidity() Return Value Returns true if the element meets all validation constraints, false otherwise. Example .valid { ...

Read More
Showing 17761–17770 of 61,299 articles
Advertisements