CoffeeScript Strings-indexOf() - CoffeeScript


This method accepts a sub string and returns the index of its first occurrence within the calling String object. It also accepts an optional parameter fromIndex which will be the starting point of the search. This method returns −1 if the value is not found.


Given below is the syntax of indexOf() method of JavaScript. We can use the same method from the CoffeeScript code.


The following example demonstrates the usage of indexOf() method of JavaScript in CoffeeScript code. Save this code in a file with name

On compiling, it gives you the following JavaScript.

Now, open the command prompt again and run the CoffeeScript file as shown below.

On executing, the CoffeeScript file produces the following output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

CoffeeScript Topics