DEV Community

Shshank
Shshank

Posted on

1 1

JavaScript startsWith() and endsWith() string methods, a brief

startsWith() and endsWith() in JavaScript are sibling methods that return a boolean true if a string starts or ends with a specific string, respectively. Else, false.

They are supported by most browsers, but Internet Explorer. They take two parameters, a search value, and a length value (optional).

Syntax: String.startsWith(string, length)

const string = "Developers love DevBytes";

string.startsWith("Dev");     // True
string.startsWith("DevBytes");   // False

string.endsWith("Bytes");     // True
string.endsWith("Dev");     // False
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay