Let\'s assume I have a huge (1000+) list of objects like this:
[{name: \'john dow\', age: 38, gender:\'m\'}, {name: \'jane dow\', age: 18, gender:\'f\'}, ..]
I wouldn't worry too much about performance in this case. A desktop computer should eat up 1000, or 10,000 evaluations without sweat. I would avoid any kind of complex optimisation because the risk of breaking functionality is probably higher than the benefit of slightly efficient processing.
Javascript (ECMAScript 5) does provide new methods for filtering arrays. As a native method it is supposed to be a little faster.
var regex = ...
results = json.filter(function(result) {
return regex.test(result.name)
}
Array.prototype.filter is supported in modern browsers, see http://kangax.github.com/es5-compat-table/. A patch for older browsers is can be added with this: https://github.com/kriskowal/es5-shim