Timeline for Find string in array using prototype functions
Current License: CC BY-SA 3.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 13, 2016 at 11:01 | vote | accept | Michael | ||
| Sep 13, 2016 at 7:28 | review | Close votes | |||
| Sep 17, 2016 at 0:05 | |||||
| Sep 13, 2016 at 7:15 | comment | added | T.J. Crowder |
@Michael: "no string exists I expect null if exists I expect true" Why would you want null rather than false?
|
|
| Sep 13, 2016 at 7:08 | comment | added | Makyen♦ | If your question is really how to use Array.prototype.find() then please edit your question to reflect that. If that is your question, please explain what it is about the documentation for that method which you don't understand. | |
| Sep 13, 2016 at 7:05 | comment | added | Makyen♦ | Another time, please use a search engine to at least make an attempt at searching for an answer prior to asking a question. The first result for a Google search for Find string in array is a duplicate of your question. | |
| Sep 13, 2016 at 7:02 | comment | added | Makyen♦ | Possible duplicate of How to find if an array contains a specific string in JavaScript/jQuery? | |
| Sep 13, 2016 at 7:02 | comment | added | nnnnnn |
If, as per your comment, you want a true or null result depending on whether the item exists (as compared to getting back the index), maybe you should edit your question to mention that, because it opens up options like .includes().
|
|
| Sep 13, 2016 at 6:59 | answer | added | pius lee | timeline score: 2 | |
| Sep 13, 2016 at 6:56 | answer | added | Paweł Mikołajczyk | timeline score: 2 | |
| Sep 13, 2016 at 6:56 | answer | added | Rashad Ibrahimov | timeline score: 2 | |
| Sep 13, 2016 at 6:55 | answer | added | T.J. Crowder | timeline score: 3 | |
| Sep 13, 2016 at 6:55 | comment | added | jedifans | As per @Rayon: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… | |
| Sep 13, 2016 at 6:55 | answer | added | illeb | timeline score: 5 | |
| Sep 13, 2016 at 6:55 | comment | added | Wiktor Zychla |
arr.find( x => x === str );
|
|
| Sep 13, 2016 at 6:54 | comment | added | Rayon |
Check console for errors... Array#find expects argument as function, not as value..
|
|
| Sep 13, 2016 at 6:54 | comment | added | Michael | @Rayon no string exists I expect null if exists I expect true | |
| Sep 13, 2016 at 6:53 | comment | added | Rayon | What are you expecting in response ? | |
| Sep 13, 2016 at 6:51 | history | asked | Michael | CC BY-SA 3.0 |