Web development

4 Ways to Check If a String Contains a Substring in JavaScript

The Short Answer There are several ways to check if a JavaScript string contains a substring. Here’s a short summary of the most notable ones. 1. string.indexOf() Use the indexOf() method. This method returns the index of the first occurrence of the substring in the string, or -1 if the substring is not found. For […]

4 Ways to Check If a String Contains a Substring in JavaScript Read More »

JavaScript How to Find Duplicates in Array (without Removing)

To find (and not delete) duplicates in a JavaScript array, you can use this function: Example use: Output: To learn how the above approach works, and what alternatives exist, please keep on reading. This guide shows you ways to find array duplicates and show them instead of deleting them. Besides, you will learn what performance

JavaScript How to Find Duplicates in Array (without Removing) Read More »

10 Easiest Programming Languages to Learn (in 2023)

There are dozens of programming languages out there. As a beginner or someone who is looking to learn a new language, it might be difficult to know where to start. There are easy languages, tricky languages, old languages, use case-specific languages, and more. If you’re completely new to programming, you might want to learn an

10 Easiest Programming Languages to Learn (in 2023) Read More »

JavaScript ‘throw new Error’ vs ‘throw Error’ vs ‘throw something’

In JavaScript the difference between throw Error and throw new Error is that: When it comes to behavior, there’s really no difference between throw Error and throw new Error. For example: But the more technically correct way to throw a new Error object is by using the throw new Error instead of throw Error. Also,

JavaScript ‘throw new Error’ vs ‘throw Error’ vs ‘throw something’ Read More »