Category: JavaScript Tutorial

python tutorials and learn python

Created with Sketch.

JavaScript String split()

JavaScript String split() Summary: in this tutorial, you’ll learn how to use the JavaScript split() method to split a string into an array of substrings. Introduction to the JavaScript String split() method The String.prototype.split() divides a string into an array of substrings: split([separator, [,limit]]); Code language: JavaScript (javascript) The split() accepts two optional parameters: separator…
Read more

Padding a String to a Certain Length with Another String

Padding a String to a Certain Length with Another String Summary: in this tutorial, you will learn how to pad a string with another string to a certain length. String.prototype.padStart() The padStart() method pads a string with another string to a certain length from the start of the string and returns a resulting string that…
Read more

JavaScript String trimEnd

JavaScript String trimEnd Summary: in this tutorial, you’ll learn how to use the JavaScript String trimEnd() method to remove whitespace characters from the end of a string. To remove the whitespace characters from the end of a string, you use the trimEnd() method: let newString = originalString.trimEnd(); Code language: JavaScript (javascript) The trimEnd() method returns…
Read more

JavaScript String trimStart

JavaScript String trimStart Summary: in this tutorial, you’ll learn how to use the JavaScript String trimStart() method to remove whitespace from the beginning of a string. To remove the whitespace characters from the beginning of a string, you use the trimStart() method: let newString = originalString.trimStart(); Code language: JavaScript (javascript) The trimStart() method returns a…
Read more

JavaScript String trim()

JavaScript String trim() Summary: in this tutorial, you’ll learn how to use the JavaScript trim() method to remove whitespace characters from both ends of a string. Introduction to the JavaScript trim() method The String.prototype.trim()returns a new string stripped of whitespace characters from beginning and end of a string: let resultString = str.trim(); Code language: JavaScript…
Read more

JavaScript String endsWith

JavaScript String endsWith Summary: in this tutorial, you will learn how to use the JavaScript String endsWith() method to check if a string ends with a substring. Introduction to the JavaScript String endsWith() method The endsWith() returns true if a string ends with the characters of a specified string or false otherwise. Here’s the syntax…
Read more

JavaScript String startsWith()

JavaScript String startsWith() Summary: in this tutorial, you will learn how to use the JavaScript String startsWith() method to check if a string starts with a substring. Introduction to the JavaScript startsWith() method The startsWith() returns true if a string starts with a substring or false otherwise. The following shows the syntax of the startsWith()…
Read more

JavaScript String includes() Method

JavaScript String includes() Method Summary: in this tutorial, you will learn how to use the JavaScript String includes() method to check if a string contains another string. Introduction to JavaScript String includes() method The includes() method determines whether a string contains another string: string.includes(searchString [,position]) Code language: CSS (css) The includes() method returns true if…
Read more

JavaScript String lastIndexOf()

JavaScript String lastIndexOf() Summary: in this tutorial, you’ll learn how to use the JavaScript String lastIndexOf() method to locate the last occurrence of a substring in a string. Introduction to the JavaScript String lastIndexOf() Method The String.prototype.lastIndexOf() returns the last occurrence of a substring (substr) in a string (str). str.lastIndexOf(substr, [, fromIndex]); Code language: JavaScript…
Read more

JavaScript String indexOf()

JavaScript String indexOf() Summary: in this tutorial, you’ll learn how to use the JavaScript String indexOf() method to find the index of a substring within a string. The String.prototype.indexOf() returns the index of the first occurrence of substring (substr) in a string (str): let index = str.indexOf(substr, [, fromIndex]); Code language: JavaScript (javascript) It returns…
Read more