Posts
@nikxco
Cancel

How to Check If a Number Is Negative or Positive Using Javascript

Sometimes we wants to know the sign of a number, it is a trivial task, but require us to write some logic in order to get it done. 1 2 3 const num = -8; // Old Way num === 0 ? num : (num > 0 ? ...

What is memoization?

We all know how useful a recursive algorithm can be, when it comes to perform actions which are repetitive in nature, some may argue that we can use loops instead of recursion, but that’s something...

Disjoint Set

Disjoint Set, also know as Union Find is a data stucture that tracks a Set of elements partitioned into number of disjoint subsets. It offers near constant time operations to add new sets, merge ex...

Can you randomly reorder an array in `O(n)`? - Fisher-Yates Modern Shuffle algorithm

This question is similar to “shuffle a deck of cards” or “randomize a given array”, here shuffle means that every permutation of array element should be equally likely. We can solve this problem i...

Hidden facts about forEach in JavaScript

We have been using forEach in JavaScript for a while now, it improves the readability of our code, but what really forEach is? Is forEach a loop in JavaScript? 1: It is not a loop Yes you heard i...

Is forEach a loop in JavaScript?

This question has confused many of us for a long time, is it a loop? or is it a function? In JavaScript a for loop repeats until a specified condition evaluates to false, it is similar to the Java...