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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -