Javascript

How to mock/test IntersectionObserver using JEST

The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document’s viewport-Mozila Let’s write a simple javascript …

How to measure time taken by a function to execute

In this post, I will show you how to measure the execution time of any function in Javascript. Javascript console api have two functions console.time and console.timeEnd . console.time - start the timer console.timeEnd …

How to randomize (shuffle) a JavaScript array?

In this article, I will show you how to shuffle an array in javascript. We will use The modern version of the Fisher-Yates shuffle, designed for computer use, was introduced by Richard Durstenfeld in 1964 The algorithm for shu…

Everything you show know about ES6 `let` keyword.

Everything you show knows about ES6 let keyword. Both var and let are used to declare variables in javascript, but the difference is that var is function scoped and let is block scoped. In this article, we will see the diffe…

ES6 JavaScript: Understanding Let & Const

Variables can be declared using const in the same way that var or let declarations are. The const keyword turns a variable into a constant whose value cannot be changed. The scoping rules for const variables are the same as t…

Flood fill algorithm in javascript

Flood fill , also called seed fill , is an algorithm that determines and alters the area connected to a given node in a multi-dimensional array with some matching attribute. It is used in the “bucket” fill tool of paint programs…

JavaScript Prototype Inheritance

In this article, I will show you how to implement inheritance in javascript. To understand the inheritance, let's get familiar with some terms. __proto__ property Every object in Javascript has its own secret, an interna…

Recursively Flatten JavaScript Array

I have started a series on the recursive problem with visualisation so that It’s easy to understand. In this problem, I will show you how to flat nested array objects using javaScript with visualisation. Let’s suppose you have …

Find All the Prime Factors of a Number-JavaScript

The process of determining which prime numbers multiply together to produce the original number is known as “prime factorization.” Algorithm Example - What are the prime factors of 12? We will start with the smallest prime num…

Difference Between var and let in JavaScript

Difference between var and  ES6 let keyword. Both var and let are used to declare variables in javascript, but the difference is that var is function scoped and let is block scoped. In this article, we will see the differenc…

Minimum coin change problem using recursion in JavaScript

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount . If …

Binary search tree using JavaScript ES6-Typescript

A binary search tree is a data structure composed of nodes. Each node has a key, which determines the node’s position in the tree. (The node may also have a “value” field, where additional data is stored.) … Specifically, eac…

تحميل المزيد من المشاركات
لم يتم العثور على أي نتائج