Skip to content

Latest commit

 

History

History

javascript-array-find

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

TypeScript - How to Find Element in Array

Source code for the article TypeScript - How to Find Element in Array.

Versions

  • TypeScript 7.0.2
  • Node.js 22 or newer

Run

npm install
npm start

npm start compiles the project and prints every value shown in the comments of the article's snippets.

Files

File Article section
src/00-quick-reference.ts Snippet with all search methods at the top of the article
src/01-find.ts 1. find() by property, early stop
src/02-undefined.ts 2. Handling the T | undefined result
src/03-narrowing.ts 3. Narrowing a union type with find()
src/04-find-index.ts 4. findIndex() and replacing an element (in place and with with())
src/05-find-last.ts 5. findLast() and findLastIndex()
src/06-by-value.ts 6. indexOf(), lastIndexOf(), includes(), NaN, literal-type arrays
src/index.ts Runs every section in order