YouTip LogoYouTip

Jsref Endswith

# JavaScript endsWith() Method [![Image 3: String Object Reference Manual](#) JavaScript String Object](#) ## Example Determine if a string ends with a specified substring (case-sensitive): let str = "Hello world"; str.endsWith("world")// Returns true str.endsWith("World")// Returns false [Try it Β»](#) * * * ## Definition and Usage The endsWith() method is used to determine whether a string ends with the characters of a specified string (case-sensitive). It returns true if the substring passed as an argument is found at the end of the string, otherwise it returns false. * * * ## Browser Support The numbers in the table specify the first browser version that fully supports the property. | | | | | | | --- | --- | --- | --- | --- | | Chrome 41 | Edge 12 | Firefox 17 | Safari 9 | Opera 36 | | Mar 2015 | Jul 2015 | Oct 2012 | Oct 2015 | Mar 2016 | * * * ## Syntax string.endsWith(searchvalue, length) ## Parameter Values | Parameter | Description | | :--- | :--- | | _searchvalue_ | Required. The string to search for. | | _length_ | Optional. The length of the string to search. Default is string.length. | ## Return Value | Type | Description | | --- | --- | | Boolean | Returns true if the string ends with the specified value, otherwise returns false. | ## Technical Details | Return Value: | Boolean. Returns true if the substring is found at the end of the string, otherwise returns false. | | --- | | JavaScript Version: | ECMAScript 6 | * * * ## More Examples ## Example Determine with different string lengths: var str = "To be, or not to be, that is the question."; str.endsWith("question."); // true str.endsWith("to be"); // false str.endsWith("to be", 19); // true [Try it Β»](#) * * JavaScript String Object](#)
← Java String IndexofJava String Equalsignorecase β†’