← All tutorials

GoCareerGo Tutorials

JavaScript Tutorial

Variables to closures, promises, the DOM and OOP — a complete JS reference.

String.prototype.indexOf()

Returns the first index of a substring, or -1.

Quick-reference summary — a full handcrafted walkthrough is coming soon for this topic.

Returns the first index of a substring, or -1.

  • Category: JS String Reference — part of the JavaScript Tutorial on GoCareerGo
  • Read the short summary above, then check the linked docs for full syntax/behaviour
  • Interview tip: be ready to explain "String.prototype.indexOf()" in one sentence, then back it up with a tiny example
// String.prototype.indexOf() — minimal example
console.log("String.prototype.indexOf()");
Tip

Quick recall: "String.prototype.indexOf()" — returns the first index of a substring, or -1.