Timeline for answer to How do I check if an array includes a value in JavaScript? by codeape
Current License: CC BY-SA 4.0
Post Revisions
54 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 30, 2023 at 11:08 | history | edited | Míng | CC BY-SA 4.0 |
add spaces after `//`
|
| Jul 19, 2022 at 12:18 | comment | added | Evgeniy Boytsov |
includes is a nice way to check. Also Array.some works well if you have objects. const users = [{name: 'Alex'}, {name: 'Jane'}]; const hasAlex = users.some(u => u.name === 'Alex');
|
|
| May 31, 2022 at 11:35 | comment | added | Timo |
Includes Works also for (sub-)string checking.
|
|
| Apr 19, 2022 at 1:07 | comment | added | user254153 |
includes function also checks for data type. [123,23].includes('23');//returns false
|
|
| Mar 28, 2022 at 21:11 | history | edited | tagurit | CC BY-SA 4.0 |
Updated links
|
| Nov 3, 2020 at 17:51 | history | edited | 3limin4t0r | CC BY-SA 4.0 |
Removed everything added in revision 35 (https://stackoverflow.com/revisions/1473742/35), since `indexOf` was already mentioned in the answer; Introduced a new minimal snippet to showcase the usage of `indexOf`.
|
| Oct 12, 2020 at 8:08 | history | edited | jps | CC BY-SA 4.0 |
bellow -> below
|
| Oct 11, 2020 at 14:35 | history | edited | Mehrzad Tejareh | CC BY-SA 4.0 |
support IE and add a reference
|
| Jun 20, 2020 at 9:12 | history | edited | Community Bot |
Commonmark migration
|
|
| Feb 11, 2020 at 19:13 | history | edited | dota2pro | CC BY-SA 4.0 |
Converting Code to Demo
|
| Jan 18, 2020 at 13:28 | history | edited | toastrackengima | CC BY-SA 4.0 |
Removed broken Polyfill link, removed EMCAScript as a "framework", moved jQuery and underscore to be with the other frameworks, and other cleanup
|
| Nov 10, 2019 at 15:36 | history | edited | Ponpon32 | CC BY-SA 4.0 |
add ramda framework
|
| Jul 31, 2018 at 17:29 | history | edited | mikemaccana | CC BY-SA 4.0 |
Add demo code
|
| Oct 15, 2017 at 0:56 | history | edited | Rach Sharp | CC BY-SA 3.0 |
Fixing broken link
|
| Sep 27, 2017 at 11:35 | history | edited | mikemaccana | CC BY-SA 3.0 |
Update for current status of .includes(). Remove non-JavaScript answers.
|
| S Sep 26, 2017 at 13:13 | history | suggested | аlex | CC BY-SA 3.0 |
* EcmaScript 6: [``array.includes(value)``][16]
|
| Sep 26, 2017 at 12:03 | review | Suggested edits | |||
| S Sep 26, 2017 at 13:13 | |||||
| Sep 13, 2017 at 8:08 | history | edited | sschoof | CC BY-SA 3.0 |
Update Url to support (moved von esnext to ex2016plus)
|
| Jan 16, 2017 at 11:30 | history | edited | Vadzim | CC BY-SA 3.0 |
Ext.Array.contains
|
| Sep 8, 2016 at 8:59 | review | Suggested edits | |||
| Sep 8, 2016 at 9:33 | |||||
| Apr 13, 2016 at 10:48 | history | edited | Benny Bottema | CC BY-SA 3.0 |
added lodash to the list
|
| Mar 21, 2016 at 1:37 | history | edited | APerson | CC BY-SA 3.0 |
reduce; simplify; update (it's 2016, people!)
|
| Feb 27, 2016 at 14:00 | review | Suggested edits | |||
| Feb 27, 2016 at 16:46 | |||||
| Aug 26, 2015 at 12:39 | history | edited | benek | CC BY-SA 3.0 |
Changed the URL to underscore since the one referenced were no more valid.
|
| S Dec 23, 2014 at 19:22 | history | suggested | Adam Parod | CC BY-SA 3.0 |
Fixed grammar
|
| Dec 23, 2014 at 18:34 | review | Suggested edits | |||
| S Dec 23, 2014 at 19:22 | |||||
| Sep 29, 2014 at 9:14 | history | edited | Benjamin Hodgson | CC BY-SA 3.0 |
the link for jquery inArray was broken
|
| Sep 7, 2014 at 22:57 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
Copy edited.
|
| Aug 5, 2014 at 14:02 | history | edited | codeape | CC BY-SA 3.0 |
Correct mochikit link
|
| Aug 5, 2014 at 13:41 | history | edited | codeape | CC BY-SA 3.0 |
CoffeeScript, fixed link
|
| Jan 16, 2013 at 9:10 | history | edited | codeape | CC BY-SA 3.0 |
Underscore contains/include
|
| Dec 10, 2012 at 19:40 | history | edited | codeape | CC BY-SA 3.0 |
added 267 characters in body; Post Made Community Wiki
|
| S Nov 19, 2012 at 22:12 | history | suggested | hopper | CC BY-SA 3.0 |
match code sample with ExtJS 4 documentation
|
| Nov 19, 2012 at 22:06 | review | Suggested edits | |||
| S Nov 19, 2012 at 22:12 | |||||
| Jul 22, 2012 at 9:45 | comment | added | Tim |
inArray is a terrible name for a function that returns the index of the element, and -1 if it doesn't exist. I would expect a boolean to be returned.
|
|
| Feb 29, 2012 at 17:17 | comment | added | plus- | Also, dont use indexOf alone as a condition, because the first element will return 0 and will be evaluated as falsy | |
| Dec 17, 2011 at 20:37 | history | edited | codeape | CC BY-SA 3.0 |
coffeescript
|
| Aug 11, 2011 at 23:38 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
added 212 characters in body; deleted 3 characters in body
|
| Jul 25, 2011 at 7:27 | history | edited | codeape | CC BY-SA 3.0 |
Fixed some outdated links
|
| S Jun 15, 2011 at 12:55 | history | suggested | Ragnar123 | CC BY-SA 3.0 |
Changed link to dojo docs - the old one was broken
|
| Jun 15, 2011 at 12:48 | review | Suggested edits | |||
| S Jun 15, 2011 at 12:55 | |||||
| Jun 15, 2011 at 10:16 | history | edited | T.J. Crowder | CC BY-SA 3.0 |
add note about the standard method at the top
|
| Feb 18, 2011 at 20:14 | history | edited | Factor Mystic | CC BY-SA 2.5 |
note underscore's include
|
| Feb 11, 2011 at 10:02 | history | edited | codeape | CC BY-SA 2.5 |
Added Ext JS
|
| Oct 19, 2010 at 17:39 | history | edited | codeape | CC BY-SA 2.5 |
underscore.js link
|
| Oct 6, 2010 at 16:17 | comment | added | Sam Soffes |
If you are using a good browser, you can just use array.indexOf(object) != -1
|
|
| Sep 10, 2010 at 22:54 | comment | added | user102008 |
prototype also has Array.include that returns a boolean
|
|
| Jun 8, 2010 at 14:10 | comment | added | Ryan Florence | MooTools also has Array.contains that returns a boolean, which sounds like the real question here. | |
| Jan 2, 2010 at 19:35 | history | edited | codeape | CC BY-SA 2.5 |
typo
|
| Jan 2, 2010 at 19:14 | history | edited | codeape | CC BY-SA 2.5 |
typo
|
| Dec 4, 2009 at 9:53 | history | edited | codeape | CC BY-SA 2.5 |
Links to other frameworks
|
| Dec 3, 2009 at 8:59 | history | edited | codeape | CC BY-SA 2.5 |
added link to jquery utilities
|
| Sep 24, 2009 at 21:50 | vote | accept | brad | ||
| Sep 24, 2009 at 19:35 | history | answered | codeape | CC BY-SA 2.5 |