About the syntax mentioned in the website https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf
They have mentioned the syntax for indexOf like this
string.indexOf(searchValue*[, fromIndex]*)
where the comma is in between the sqaure brackets, but when we use the function the value is entered is after the comma.
Is this a kind of standard methodology for showing the syntax?
Yes, it's fairly standard. Items appearing inside []
brackets are optional. If you're not going to provide the second parameter, then you don't supply the comma either.
You wouldn't write indexOf('abc',);