endsWith in javascript

Posted by Bobby Kumar on Stack Overflow See other posts from Stack Overflow or by Bobby Kumar
Published on 2008-11-11T11:15:32Z Indexed on 2010/03/30 19:43 UTC
Read the original article Hit count: 424

Filed under:
|

How can I check if a string ends with a particular character in javascript? example I have a string say var str = "mystring#"; I want to know if that string str is ending with "#". How can I check it?

  1. is there a endsWith() method in javascript?

  2. one solution I have is take the length of the string and get the last character and check it.

Is this the best way or there is any other way?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about strings