How to enable a strict mode in javascript?

Arnab Chakraborty
Updated on 15-Mar-2026 23:18:59

197 Views

In JavaScript, there are two different programming paradigms. The sloppy mode, sometimes referred to as the simple mode, is activated by default. We don't have to write the code strictly according to guidelines in this manner. On the other side, there is also the strict mode. This setting allows the environment to have some rigid constraints. Strict mode has different semantics than regular code and is not a subset of sloppy mode. This article will explain how to enable strict mode in JavaScript and will also go over some of the features of "Strict" Mode. Syntax Different scopes ... Read More

How to reduce an array while merging one of its field as well in JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:18:59

561 Views

Consider, we have the following array of objects − const arr = [{ id: 121, hobby: 'cycling' }, { id: 125, hobby: 'jogging' }, { id: 129, hobby: 'reading' }, { id: 121, hobby: 'writing' }, { id: 121, hobby: 'playing football' }, { id: 125, hobby: 'cooking' }, { id: 129, hobby: 'horse riding' }]; ... Read More

Comparing ascii scores of strings - JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:18:59

1K+ Views

ASCII is a 7-bit character encoding standard where every character has a unique decimal code. In JavaScript, we can use the charCodeAt() method to get the ASCII value of any character. This article demonstrates how to compare two strings by calculating their ASCII scores (the sum of ASCII values of all characters) and finding the difference between them. Understanding ASCII Values Each character has a specific ASCII decimal value: console.log('A'.charCodeAt(0)); // 65 console.log('a'.charCodeAt(0)); // 97 console.log(' '.charCodeAt(0)); // 32 (space) console.log('1'.charCodeAt(0)); // 49 65 97 32 49 ... Read More

Counting below / par elements from an array - JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:18:59

262 Views

We are required to write a function that counts how many elements in an array are below or at/above a given number. Following is our array of Numbers − const array = [54, 54, 65, 73, 43, 78, 54, 54, 76, 3, 23, 78]; For example, if the number is 60, there should be 7 elements below it − 54, 54, 43, 54, 54, 3, 23 and 5 elements at or above it − 65, 73, 78, 76, 78 Using Array.reduce() Method The reduce() method processes ... Read More

How can I list all cookies on the current page with JavaScript?

Smita Kapse
Updated on 15-Mar-2026 23:18:59

1K+ Views

In JavaScript, you can list all cookies on the current page using the document.cookie property. This property returns a string containing all cookies as semicolon-separated key-value pairs. Basic Cookie Retrieval The simplest way to get all cookies is to access document.cookie directly: // Set some sample cookies first document.cookie = "username=john; path=/"; document.cookie = "theme=dark; path=/"; ... Read More

Find the non-digit character with JavaScript Regular Expression

Sravani Alamanda
Updated on 15-Mar-2026 23:18:59

2K+ Views

In this tutorial, we will learn to find non-digit characters using JavaScript regular expressions. The \D metacharacter matches any character that is not a digit (0-9), including letters, spaces, and special characters. RegExp is an object that specifies patterns used for search and replace operations on strings or input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Syntax The syntax for matching non-digit characters is: new RegExp("\D") // Constructor syntax /\D/ // Literal syntax (recommended) ... Read More

How to use JavaScript DOM to change the padding of a table?

Abhishek
Updated on 15-Mar-2026 23:18:59

1K+ Views

In this tutorial, we learn to use JavaScript DOM to change the padding of a table. To change the padding of a table, use the DOM padding property. The HTML table is used to display relational data on the user screen. We can easily show related or dependent data to the user and user can easily understand and determine the characteristics of the data with help of table. But, while we are showing the relational data to the user in the form of table, we need to make sure that the table is well structured and looking good according ... Read More

HTML5 Cross Browser iframe post message - child to parent?

George John
Updated on 15-Mar-2026 23:18:59

281 Views

HTML5's postMessage API enables secure communication between an iframe and its parent window across different domains. This is essential for cross-origin iframe communication where traditional methods fail due to browser security policies. Parent Window Setup The parent window needs to set up an event listener to receive messages from the child iframe. Here's the cross-browser compatible approach: Parent Window Parent Window ... Read More

Set the font weight with CSS

varun
Updated on 15-Mar-2026 23:18:59

259 Views

The font-weight property controls how bold or light text appears. It accepts keyword values like normal and bold, or numeric values from 100 to 900. Syntax font-weight: normal | bold | bolder | lighter | 100-900; Font Weight Values Value Description Numeric Equivalent normal Regular text weight 400 bold Bold text weight 700 bolder Bolder than parent element Relative lighter Lighter than parent element Relative Example: Different Font Weights Font Weight Example ... Read More

Asynchronous Functions and the Node Event Loop in Javascript

sudhir sharma
Updated on 15-Mar-2026 23:18:59

224 Views

Asynchronous functions allow programs to continue executing without waiting for time-consuming operations to complete. This non-blocking behavior is fundamental to JavaScript and Node.js, enabling better user experience and efficient resource utilization. When executing expensive operations like network requests or file I/O, asynchronous functions prevent the entire program from freezing. Instead of blocking execution, these operations run in the background while other code continues to execute. Understanding Asynchronous Execution In synchronous programming, each operation must complete before the next one begins. Asynchronous programming allows multiple operations to run concurrently, with callbacks or promises handling completion. console.log('One'); ... Read More

Advertisements