Sling Academy
Home/JavaScript/Page 88

JavaScript

JavaScript: How to Capitalize all Words in a String

Updated: Feb 22, 2023
Capitalizing all words in a string can be useful in situations where you want to standardize the formatting of text, such as when displaying titles or headings. This concise, example-based article will show you how to do that in......

JavaScript: How to Count Words in a String

Updated: Feb 22, 2023
Counting the number of words in a string can be a useful task for various applications, such as analyzing text data or creating word games. This succinct, practical article will show you how to do so in JavaScript. A Common......

3 Ways to Validate an Email Address in JavaScript

Updated: Feb 20, 2023
This practical, example-based article walks you through 3 different ways to validate an email address in JavaScript. Using a Regular Expression (Regex) This is the most common and flexible approach to checking if a string is a valid......

JavaScript: How to Convert a String to a URL Slug

Updated: Feb 20, 2023
In the world of web development, a slug is a URL-friendly version of a string, typically used in URLs to identify a specific page or resource. A slug usually consists of lowercase characters, numbers, and hyphens (or underscores), with......

[JS] Generate a random number between Min and Max and exclude a specific number

Updated: Feb 20, 2023
Creating a random number is popular stuff in Javascript that has many use cases. This article shows you how to generate a random number between a minimum number (inclusive) and a maximum number (exclusive), and the random number you......

Calculate Variance and Standard Deviation in JavaScript

Updated: Feb 20, 2023
This practical, succinct article shows you how to calculate the variance and standard deviation of a given array of numbers. You will see the code in vanilla Javascript and TypeScript. Javascript // Calculate the average of all the......

JavaScript: Remove Leading & Trailing Whitespace from a String

Updated: Feb 20, 2023
This article is about removing leading and trailing whitespace from a string in JavaScript, a common task that you’ll likely encounter when developing web apps. Remove Both Leading & Trailing Whitespace This is a......

Switch Statement in Javascript: Tutorial & Examples

Updated: Feb 20, 2023
This article is about switch statements in Javascript. Overview A switch statement is a control structure that allows you to perform different actions based on different conditions. It works by evaluating an expression and then......

Enums in Javascript: Tutorial & Examples

Updated: Feb 20, 2023
This succinct, straight-to-the-point article is about enums in Javascript. You will learn what an enum is and how it can be used. Overview An enum, short for enumeration, is a data type that allows a developer to define a set of......

null, undefined, NaN, and false in Javascript

Updated: Feb 20, 2023
This concise and straight-to-the-point article is about null, undefined, NaN, and false in JavaScript. Overview null and undefined are both used to represent the absence of a value, but null is usually used when you intentionally......

How to effectively use the filter() method in Javascript

Updated: Feb 19, 2023
This concise and straightforward article shows you how to effectively use the filter() method in Javascript. The Fundamentals The filter() method is used to extract values from an array based on a specified condition. It takes a......

How to use the for…of loop in JavaScript (best practices)

Updated: Feb 19, 2023
This article covers everything you need to know about the for…of loop in JavaScript. Overview The for…of loop is a useful feature of JavaScript that simplifies the process of iterating over arrays, strings, and other iterable......