1 2 if ( !Object.getPrototypeOf ) 3 Object.getPrototypeOf = function(obj) { 4 return obj.__proto__; 5 }; 6 7 function isString(str) { 8 return typeof str === 'string' || str instanceof String; 9 } 10 11 function isNumber(num) { 12 return typeof num === 'number' || num instanceof Number; 13 } 14 15 function isArray(arr) { 16 return arr instanceof Array; 17 } 18 19 function isObject(obj) { 20 return Object.getPrototypeOf(obj) === Object.prototype; 21 } 22 23 function isFunction(fn) { 24 return typeof fn === 'function'; 25 } 26 27