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
Finding the longest consecutive appearance of a character in another string using JavaScript
Problem We are required to write a JavaScript function that takes in a string as the first argument and a single character as the second argument. Our function should count and return the longest consecutive appearance of the character in the string. Approach We'll iterate through the string and track the current consecutive count and maximum count found so far. When we encounter the target character, we increment the counter. When we encounter a different character, we reset the counter. Example Following is the code − const str = 'abcdaaadse'; const char ...
Read Morecrypto.randomBytes() Method in Node.js
The crypto.randomBytes() method generates cryptographically strong pseudo-random data in Node.js. This method ensures sufficient entropy before completion, typically taking only a few milliseconds to generate secure random bytes. Syntax crypto.randomBytes(size, [callback]) Parameters The parameters are described below: size – Specifies the number of bytes to generate. Must not exceed 2**31 - 1. callback – Optional callback function called if an error occurs. If omitted, the method runs synchronously. Asynchronous Example ...
Read MoreWhat is the SectionList component and how to use it in React Native?
The SectionList component in React Native provides an efficient way to display data organized in sections with headers. It's perfect for categorized lists like contacts, settings, or grouped items. Key Features Header/Footer support for the entire list Header/Footer support for individual sections Scroll loading and pull-to-refresh functionality Cross-platform compatibility Sticky section headers Basic Syntax import { SectionList } from "react-native"; Important Props ...
Read MoreHow to add dashes to the border of a selection area on a canvas using FabricJS?
In this article, we are going to learn how to add dashes to the border of a selection area on a canvas using FabricJS. We can achieve this by using the selectionDashArray property. It allows us to make the border of a selection area dashed. Syntax new fabric.Canvas(element: HTMLElement|String, { selectionDashArray: Array }: Object) Parameters element − This parameter is the element itself which can be derived using document.getElementById() or the id of the element itself. The FabricJS canvas will be ...
Read MoreHow to set the style of controlling corners of a Rectangle using FabricJS?
In this tutorial, we are going to learn how to set the style of controlling corners of a Rectangle using FabricJS. Rectangle is one of the various shapes provided by FabricJS. In order to create a rectangle, we will have to create an instance of fabric.Rect class and add it to the canvas. The controlling corners of an object allow us to scale, stretch or change its position. We can customize our controlling corners in many ways such as adding a specific colour to it, changing its size etc. We can change the style by using ...
Read MoreHow to call promise inside another promise in JavaScript?
When working with JavaScript, you may find yourself needing to call a promise inside another promise. While this may seem like a daunting task, it is actually quite simple once you understand the basics of promises. In this article, we will discuss how to call a promise inside another promise in JavaScript. The Basics of Promises In order to understand how to call a promise inside another promise, it is important first to understand the basics of promises. A promise is an object that represents the eventual result of an asynchronous operation. Promises are used in JavaScript to ...
Read MoreIs it possible to change the value of the function parameter in JavaScript?
In this article we are going to find out whether it is possible to change the value of the function parameter in JavaScript. A function accepts certain values as parameters and later while calling this function we need to pass values for these parameters as arguments. Typically a function definition contains the name of the function, parameters (optional) and the body of the function. Syntax Following is the syntax for function parameters − function functionName(parameter1, parameter2, parameter3) { // Statements } Yes, it is possible to change the value of ...
Read MoreSearch a complex object by id property in JavaScript
Suppose we have a complex JSON Object like this − const obj = { "id": "0001", "fieldName": "sample1", "fieldValue": "0001", "subList": [ { "id": 1001, "fieldName": "Sample Child 1", "fieldValue": "1001", "subList": [] }, { "id": 1002, "fieldName": "Sample Child 2", ...
Read MoreMeeting Rooms 2 problem in JavaScript
We will be given an array of arrays, each subarray consists of exactly two elements indicating the start and end time of a meeting. The task of our function is to find the maximum number of meetings one person can take avoiding the conflict of time. The function should finally return this number. For example − If the input array describing meeting times is − const arr = [[5, 40], [10, 20], [25, 35]]; Then the output should be − const output = 2; because it's not possible to ...
Read MoreReturning lengthy words from a string using JavaScript
We are required to write a JavaScript function that takes in a sentence of words and a number. The function should return an array of all words greater than the length specified by the number. Problem Statement Input: const str = 'this is an example of a basic sentence'; const num = 4; Expected Output: const output = [ 'example', 'basic', 'sentence' ]; Because these are the only three words with length greater than 4. Using for Loop The most straightforward approach is to split the string into ...
Read More