In Java you have some cool String functions like startsWith which can be used like this:
public static void main(String[] args) { boolean startsWith = "Hello World".startsWith("Hello"); System.out.println(startsWith); // true } |
In JavaScript you can have something similar with a bit of work:
<script type="text/javascript"> String.prototype.startsWith = function(pattern){ return (this.match('^' + pattern) == pattern); } var startsWith = "Hello World".startsWith("Hello"); document.write(startsWith); // true </script> |