Syntax

JavaScript Find in Array Syntax

In JavaScript, find in array: returns the first item that passes a test — users.find((u) => u.id === id)

Quick Answer

Syntax
users.find((u) => u.id === id)
JavaScriptSyntax

Find in Array

Code example
users.find((u) => u.id === id)

Returns the first item that passes a test.

Learn More

How to find in array in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Find in Array Syntax

Use users.find((u) => u.id === id).

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for find in array?

Use this pattern: users.find((u) => u.id === id)

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify