In this short tutorial, we are going to see what the
endsWith method is used to find out if a string ends with the character or substring you pass as a parameter to the method. The
endsWith method works with any type of string. It is accepted by standard strings declared with single or double quotes, as well as by
String objects or literal templates.
endsWith method will return
true if the string begins with the given substring or
const achain = 'a chain'; achain.endsWith('ain'); // true achain.endsWith('Hello');// false
endsWith method also accepts a second optional parameter that allows the length of the string to be delimited to the specified character when checking. The character is specified by its numeric position, starting at position
const achain = 'a chain'; achain.endsWith('ch', 4); // true achain.endsWith('ch', 5); // false
In the following example we use an object of type string, which behaves in exactly the same way:
const achain = new String('a chain'); achain.endsWith('ch', 4); // true achain.endsWith('ch', 5); // false
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN AND DEVELOPMENT.
The Payment Request API: Revolutionizing Online Payments (Part 2)
Part 2: Advanced Features and Best Practices In the first part of this series, we explored the fundamentals of the Payment Request API and how it simplifies the payment experience. Now,…
The Payment Request API: Revolutionizing Online Payments (Part 1)
The Payment Request API has emerged as the new standard for online payments, transforming the way transactions are conducted on the internet. In this two-part series, we will delve into…
A sleep()function is a function that allows you to stop the execution of code for a certain amount of time. Using a function similar to this can be interesting for…
I have long wanted to talk about how infinite scroll functionality can be implemented in a list of items that might be on any Web page. Infinite scroll is a technique…
Sorting elements with SortableJS and storing them in localStorage
What is a JWT token and how does it work?
JWT tokens are a standard used to create application access tokens, enabling user authentication in web applications. Specifically, it follows the RFC 7519 standard. What is a JWT token A JWT token…
Symbols are a new primitive value introduced by ES6. Their purpose is to provide us unique identifiers. In this article, we tell you how they work, in which way they…