String.startsWith(): This method returns if the string begins with specified value.
<!doctype html>
<html>
<body>
<script>
var line = "Online web technologies session";
var found = line.startsWith("Online");
if(found)
document.write("Start with Online");
else
document.write("Not starts with Online");
</script>
</body>
</html>
String.endsWith():
- Check the given string ends with specified value or not.
- If ends with value, it returns true else it returns false.
<!doctype html>
<html>
<body>
<script>
var line = "Online web technologies session";
var found = line.endsWith("Online");
if(found)
document.write("ends with Online");
else
document.write("Not ends with Online");
</script>
</body>
</html>