---
title: "Discussion on \"JavaScript indexOf() method Explained with Examples\" | Hashnode"
description: "Discussion on \"JavaScript indexOf() method Explained with Examples\". The indexOf() method is a commonly used method in JavaScript for strings and arrays. It is used to find the index of the first occurrence of a specified value within the string or array. If the value is not found, it returns -1.\nFor Strings:\nSyntax:\n..."
url: "https://hashnode.com/posts/javascript-indexof-method-explained-with-examples/658e92663f456113d8fab3a3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript indexOf() method Explained with Examples](https://xdcoder.hashnode.dev/javascript-indexof-method-explained-with-examples?utm_source=hashnode&utm_medium=feed)

The indexOf() method is a commonly used method in JavaScript for strings and arrays. It is used to find the index of the first occurrence of a specified value within the string or array. If the value is not found, it returns -1. For Strings: Syntax: ...

Dec 29, 2023 · 2 min read · xdcoder.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#methods](https://hashnode.com/tag/methods)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#programming-languages](https://hashnode.com/tag/programming-languages)
-   [#codenewbies](https://hashnode.com/tag/codenewbies)

## Written by

[Aditya Sharma](https://hashnode.com/@xdcoder)

@xdcoder · Bengaluru, India

  
[View profile](https://hashnode.com/@xdcoder)

I build things for the web.

I am a web developer from Bengaluru, India. My mission is to turn your vision into a compelling digital experience. I'm here to collaborate and bring your ideas to life. Let's build something amazing together!

## Responses 1

Markdown supported · ⌘↵ to post

[Aditya Sharma](https://hashnode.com/@xdcoder)

[Dec 29, 2023](https://hashnode.com/posts/javascript-indexof-method-explained-with-examples/658e92663f456113d8fab3a3/comment/658e95a1f073040c2d27210e)

Amazing post
