javascript - Why do we use to detect type of object is function? -
why use in javascript application this:
if ( typeof object.create !== 'function' ) { object.create = function( obj ) { function f() {}; f.prototype = obj; return new f(); }; }
this called polyfill -- detects whether feature of javascript supported current users browser, , if it's not there, defines other scripts come page run on browser.
Comments
Post a Comment