Sling Academy
Home/JavaScript/Page 87

JavaScript

How to Convert a String into an Array in JavaScript

Updated: Feb 28, 2023
In JavaScript, you can use the built-in split() method to split a string into an array of substrings based on a specified delimiter: string.split(separator, limit) Parameters ParameterDescriptionseparatorOptional. Specifies the......

JavaScript Regular Expressions: Extract & Validate URLs

Updated: Feb 27, 2023
This concise article shows you how to use regular expressions to extract and validate URLs in JavaScript. No more delay; let’s get to the point. Extracting URLs To extract URLs from a string, use the match() method with this......

4 Ways to Extract a Substring from a String in JavaScript

Updated: Feb 27, 2023
Substring extraction means retrieving a portion of a string based on certain criteria. This succinct, practical article will walk you through a few different ways to extract a substring from a given string in JavaScript. No time to waste;......

2 Ways to Check if a String is Empty in JavaScript

Updated: Feb 27, 2023
An empty string is a string that contains no characters at all. This concise article shows you 2 different ways to check whether a given string is empty or not in JavaScript. Note: A string that contains only whitespace characters,......

3 Ways to Reverse a String in JavaScript

Updated: Feb 27, 2023
Reversing a string means changing its order so that the last character becomes the first, and the second last character becomes the second, and so on. This straightforward, example-based article shows you a couple of different ways to......

JavaScript: Convert a String to Upper or Lower Case

Updated: Feb 27, 2023
This concise article shows you how to convert a string to upper or lower case in JavaScript, from theory to practical examples. Overview To convert a given string to uppercase, you can use the toUpperCase() method. To convert a......
Try…Catch…Finally in JavaScript

Try…Catch…Finally in JavaScript

Updated: Feb 27, 2023
This article is about the try…catch…finally statement in JavaScript. Overview Try…catch…finally is a JavaScript feature that helps handle errors in code. It allows developers to attempt a risky operation in the try......

JavaScript: 2 Ways to Remove HTML Tags from a String

Updated: Feb 25, 2023
When developing web applications, there might be an enormous number of times when we need to remove HTML tags from a string, such as: When working with content that will be used in an email or other message format where HTML tags are......

How to Escape Special Characters in a String in JavaScript

Updated: Feb 25, 2023
In JavaScript, certain characters have special meanings and are used to represent various values and formatting within a string. For example, the double quote (“) character is used to indicate the beginning and end of a string. If a......
4 Ways to Generate Random Strings in JavaScript

4 Ways to Generate Random Strings in JavaScript

Updated: Feb 25, 2023
When developing web projects (either front-end or back-end), random strings are commonly used for various purposes, such as making unique identifiers for user accounts or objects in a database or creating random file names to avoid naming......
JavaScript: Get current date time in yyyy/MM/dd HH:mm:ss format

JavaScript: Get current date time in yyyy/MM/dd HH:mm:ss format

Updated: Feb 24, 2023
This concise article shows you how to get the current date and time in Javascript in yyyy/MM/dd HH:mm:ss format. We’ll write code from scratch without using any third-party libraries. In the example below, we will create a new......

Ways to Make Comments in JavaScript

Updated: Feb 22, 2023
This concise and straight-to-the-point article walks you through different ways to make comments in JavaScript. Line Comment A line comment starts with two forward slashes // and ends at the end of the line. Line comments are used......