<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba" -->

---
title: Array.includes() checks the value. | daily.dev
description: `Array.includes()` can tell you whether a value exists in an array at runtime, but inside an `if` TypeScript may still see the value as just `string`. A type...
canonical: https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Array.includes() checks the value. | daily.dev
og:description: `Array.includes()` can tell you whether a value exists in an array at runtime, but inside an `if` TypeScript may still see the value as just `string`. A type...
og:url: https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba
og:image: https://api.daily.dev/og/posts/AeAIwbgbA.png
og:image:alt: Array.includes() checks the value.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Array.includes() checks the value.

**[Web Developement](https://daily.dev/sources/webdevelopement)** · [@nyaomaru](https://daily.dev/nyaomaru) · 1 min read · 0 upvotes · 0 comments

## Summary

`Array.includes()` can tell you whether a value exists in an array at runtime, but inside an `if` TypeScript may still see the value as just `string`. A type guard can do both: check the value at runtime and narrow the type. The `oneOfValues()` function in the is-kit library does that.

## Content

A small TypeScript trap. 👀

`Array.includes()` can tell you whether a value exists in an array at runtime.

But even inside the `if`, TypeScript may still see the value as just `string`. 🙀

A type guard can do both:

✅ check the value at runtime

✅ narrow the type

That’s what `oneOfValues()` in is-kit does. 😸

https://github.com/necoz-oss/is-kit

#TypeScript #JavaScript #OpenSource

## Similar posts on daily.dev

- [How to Defend Your JavaScript App Against Unsafe Data with TypeScript Guard Utilities](https://daily.dev/posts/how-to-defend-your-javascript-app-against-unsafe-data-with-typescript-guard-utilities-cuooqjnij) · freeCodeCamp · 5 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#typescript](https://daily.dev/tags/typescript)

[View this post on daily.dev](https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba","headline":"Array.includes() checks the value.","text":"`Array.includes()` can tell you whether a value exists in an array at runtime, but inside an `if` TypeScript may still see the value as just `string`. A type guard can do both: check the value at runtime and narrow the type. The `oneOfValues()` function in the is-kit library does that.","url":"https://daily.dev/posts/array-includes-checks-the-value--aeaiwbgba","datePublished":"2026-11-16T17:42:01.968Z","dateModified":"2026-11-16T17:45:49.608Z","author":{"@type":"Person","name":"nyaomaru","url":"https://daily.dev/nyaomaru","image":"https://avatars.githubusercontent.com/u/90489696?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"image":"https://media.daily.dev/image/upload/s--_rL_sBaN--/f_auto,pg_1/v1794850922/posts/AeAIwbgbA?_a=BAMAMiiw0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/webdevelopement","name":"Web Developement"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Web Developement","item":"https://daily.dev/squads/webdevelopement"},{"@type":"ListItem","position":3,"name":"Array.includes() checks the value."}]}
```

