Underscore.js filter not returning all results [duplicate]
问题 This question already has answers here : Why does a RegExp with global flag give wrong results? (6 answers) Closed 2 years ago . I am trying to build an filtering function that works similar to the way an auto-complete field would work. I am using Underscore.js to filter an array of names. Here is a JSFiddle that demonstrates the problem: http://jsfiddle.net/PWcVM/ And for those who would rather not jump to JSFiddle, here is the example in plain text. HTML: <p>Type the name 'Craig' into the