ember.js - How findQuery works in Ember local storage adapter -
in findquery
function of ember local storage adapter, i'm confused this line containing "[object regexp]"
. mean?
if (object.prototype.tostring.call(test) == '[object regexp]') { push = test.test(record[property]); } else { push = record[property] === test; }
[object regexp]
string representation (tostring()
) of regular expression object in javascript.
that part of code checks if query regular expression. if so, runs expression object's test()
on property, otherwise strict ===
comparison.
try running in console:
var test = /a.*?nice regex/; var string = "is nice regex?"; console.log( object.prototype.tostring.call(test) ); console.log( test.test(string) );
Comments
Post a Comment