Search
The endsWith() method returns true if the string ends with the given substring and returns false otherwise.
endsWith()
true
false
In the example given above, sam@example.com ends with the substring @example.com, hence email.endsWith("@example.com") returns true.
sam@example.com
@example.com
email.endsWith("@example.com")