Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 171 of 377

How to know whether a value is searched in Javascript sets?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 236 Views

In JavaScript, sets are collections of unique values. Sometimes you need to check whether a specific element exists inside a set. In this article, we will explore different techniques to verify element presence in JavaScript sets. Using for Loop (Manual Search) You can search for an element by iterating through the set and comparing each element with the target value. If found, return true; otherwise, return false after checking all elements. HTML Console Output Console Output: ...

Read More

How to make your code faster using JavaScript Sets?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 1K+ Views

While writing code, we always try to make our code easier to read, less complex, more efficient, and smaller in size. For that, we follow several methodologies which make our code efficient. In this article, we shall focus on some techniques based on JavaScript Sets to perform certain array-like or collection-based applications which will run faster and the code will also be concise. How Sets Differ from Arrays Arrays are indexed collections where each element is associated with a specific index. On the other hand, Sets are keyed collections where data elements are ordered based on their key ...

Read More

Mixins in JavaScript

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 3K+ Views

Multiple-inheritance is not supported by JavaScript by default. But sometimes we need to mix multiple object properties into a single object. Object property sharing can be done using mixins. In this article, we shall cover what are mixins in JavaScript. The definition of mixins can be stated as mixins is a class that contains methods that can be used by other classes without inheriting from that class. The methods in mixin provide certain behavior which is not used alone but can be used to add these behaviors to other classes. Basic Mixin with Object.assign() See the following ...

Read More

How to return the response from an asynchronous call in Javascript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 495 Views

Asynchronous programming is common in JavaScript network programming. In this approach, we can download data or perform time-dependent operations without blocking the current execution flow. This article explores techniques to return responses from asynchronous calls in JavaScript. Before diving into solutions, let's examine a common problem developers face with asynchronous calls: The Problem function aTrivialFunction() { ajaxCall(..., function onSuccess(result) { // How do we return result from this function? }); } console.log('result of aTrivialFunction:', aTrivialFunction()); // undefined This AJAX call represents a ...

Read More

How to pretty print json using javascript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 1K+ Views

JavaScript Object Notation (JSON) is a standard format for storing and exchanging data. When working with JavaScript objects, displaying them in a readable format can be challenging, especially with complex nested structures. This article explores methods to pretty print JSON using JavaScript's built-in capabilities. The Problem with Default Object Display When you directly display a JavaScript object, it often appears as [object Object] or in a compact, unreadable format. Let's see this with a simple example: JSON Pretty Print Demo Output Console ...

Read More

What are the characteristics of JavaScript 'Strict Mode'?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 458 Views

JavaScript strict mode enables stricter parsing and error handling in your JavaScript code. By default, JavaScript runs in "sloppy mode" which allows certain questionable practices. Strict mode helps you write more secure and optimized code by catching common coding mistakes. Syntax Strict mode can be enabled in different scopes using the "use strict" directive: Global Strict Mode "use strict"; // All code in this script runs in strict mode Function Strict Mode function myFunction() { "use strict"; // Only this function runs in strict mode ...

Read More

Memory Management in JavaScript

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

Memory management is an essential task when writing effective programs. In JavaScript, unlike low-level languages like C and C++, memory allocation and deallocation are handled automatically. However, understanding memory management concepts helps developers write more efficient code and avoid memory leaks. Memory management in any programming language involves three important phases, termed as memory life-cycle: Allocating the memory which is required in our program. Utilize the allocated memory unit. After completion, clear the memory block. Memory Allocation Strategies in JavaScript Value Initialization In JavaScript, ...

Read More

C program to demonstrate usage of variable-length arrays

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 392 Views

Variable-length arrays (VLAs) in C allow you to create arrays whose size is determined at runtime rather than compile time. This feature was introduced in C99 and provides dynamic array allocation on the stack. In this example, we'll demonstrate a library system that uses VLAs to manage books on shelves with three operations: adding books, querying book pages, and counting books per shelf. Syntax data_type array_name[variable_size]; // Where variable_size is determined at runtime Library Management System The system supports three commands − Command 1: Insert a book with y pages at shelf ...

Read More

C program to find out the maximum value of AND, OR, and XOR operations that are less than a given value

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

Suppose we are given two integers k and n. Our task is to perform three operations; bitwise AND, bitwise OR, and bitwise XOR between all pairs of numbers up to range n. We return the maximum value of all three operations between any two pairs of numbers that is less than the given value k. So, if the input is like n = 5, k = 5, then the output will be 4 3 4. The greatest value of AND, OR, and XOR operations between all pairs of numbers that are less than 5 are 4, 3, and ...

Read More

C program to sort triangles based on area

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 904 Views

Suppose we have an array of different triangles where triangles[i] = [ai, bi, ci] these are the sides of ith triangle. We shall have to sort the triangles based on their area. The area of a triangle using sides is calculated with Heron's formula: square root of p*(p-a)*(p-b)*(p-c) where p = (a+b+c)/2. So, if the input is like (7, 24, 25), (5, 12, 13), (3, 4, 5), then the output will be (3, 4, 5), (5, 12, 13), (7, 24, 25) Syntax struct Triangle { int a, b, c; }; int ...

Read More
Showing 1701–1710 of 3,768 articles
« Prev 1 169 170 171 172 173 377 Next »
Advertisements