Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to clone an object in JavaScript?
An object is said to be an entity which has properties and types in it. Example, consider a Person as an object and it has properties like height, weight, age and salary. In the similar way JavaScript also have objects and their defined properties. An object in JavaScript is a complicated data type where it can store various data types in it. Let's consider this example below: const employee = { ...
Read MoreExplain Behavior Driven Framework.
Behavior Driven Development (BDD) is a software development framework that brings together all project stakeholders including developers, testers, product owners, managers, customers, and business analysts. The main goal is to ensure everyone shares the same understanding of the application's requirements and behavior. BDD emphasizes collaboration and coordination among team members by describing functional requirements in plain, non-technical language that everyone can understand. This eliminates the need for deep technical coding knowledge when discussing specifications. How BDD Works The BDD process follows a structured approach that focuses on the application's behavior rather than its technical implementation: ...
Read MoreFlattening multi-dimensional arrays in JavaScript
JavaScript arrays can be nested to create multi-dimensional structures. Flattening converts these nested arrays into a single-level array. The flat() method provides a clean solution for this operation. Syntax array.flat(depth) Parameters depth (optional): The number of nested levels to flatten. Default is 1. Use Infinity to flatten all levels. Basic Example Array Flattening Demo Flattening Multi-dimensional Arrays ...
Read MoreCheck whether a series of operations yields a given number with JavaScript Recursion
By starting from the number 1 and repeatedly either adding 5 or multiplying by 3, an infinite amount of new numbers can be produced. We are required to write a function that, given a number, tries to find a sequence of such additions and multiplications that produce that number. And returns a boolean based on the fact whether or not there exists any such sequence. For example, the number 13 could be reached by first multiplying by 3 and then adding 5 twice (1 × 3 = 3, 3 + 5 = 8, 8 + 5 = 13), so ...
Read MorePronic numbers in JavaScript
A Pronic number is a number which is the product of two consecutive integers, that is, a number of the form n(n + 1). For example, 6 is a Pronic number because 6 = 2 × 3, and 12 is Pronic because 12 = 3 × 4. We are required to write a JavaScript function that takes in a number and returns true if it is a Pronic number otherwise returns false. Understanding Pronic Numbers The first few Pronic numbers are: 0, 2, 6, 12, 20, 30, 42, 56, 72, 90... ...
Read MoreHow to set multiple cookies in JavaScript?
In JavaScript, you can set multiple cookies by calling document.cookie multiple times. Each call adds a new cookie to the browser's cookie store. Unlike other properties, document.cookie doesn't overwrite existing cookies — it appends new ones. Basic Syntax for Multiple Cookies document.cookie = "cookie1=value1"; document.cookie = "cookie2=value2"; document.cookie = "cookie3=value3"; Example: Setting Multiple Cookies Here's a complete example showing how to add, list, and remove multiple cookies: var num = 1; ...
Read MoreWhat will happen when 1 is converted to Boolean in JavaScript?
In JavaScript, when the number 1 is converted to Boolean, it becomes true. This is because 1 is considered a "truthy" value in JavaScript's type conversion system. Understanding Truthy and Falsy Values JavaScript has specific rules for Boolean conversion. The number 1 (and all non-zero numbers) are truthy values, meaning they convert to true. Example: Converting 1 to Boolean Convert 1 to Boolean var myVal = 1; document.write("Boolean: " ...
Read MoreHow to add comments in the style sheet blocks
You may need to put additional comments in your stylesheet blocks. Therefore, it is very easy to comment any part of the style sheet. You can simply put your comments inside /*...this is a comment in style sheet...*/. You can use /* ... */ to comment multi-line blocks in a similar way you do in C and C++ programming languages. Syntax /* Single-line comment */ /* Multi-line comment can span multiple lines */ Example: Adding Comments to CSS ...
Read MoreFind the middle element of an array using recursion JavaScript
We are required to write an array function, say findMiddle that returns the middlemost element of the array without accessing its length property and without using any kind of built-in loops. If the array contains an odd number of elements, we return the one, middlemost element, or if the array contains an even number of elements, we return an array of two middlemost elements. So, let's write the code for this function. As you've already guessed, we will be making use of recursion to find these elements. The code for the recursive function will be — How It ...
Read MoreProgram to find uncommon elements in two arrays - JavaScript
Finding uncommon elements in two arrays means identifying elements that exist in one array but not in both. This is also known as finding the symmetric difference between two arrays. Problem Definition Given two arrays, we need to find elements that are present in either the first array or the second array, but not in both arrays. const arr1 = [12, 54, 2, 4, 6, 34, 3]; const arr2 = [54, 2, 5, 12, 4, 1, 3, 34]; console.log("Array 1:", arr1); console.log("Array 2:", arr2); Array 1: [12, 54, 2, 4, 6, 34, ...
Read More