I can not understand why in this function to use the Object.prototype in order to check the input and determine whether it is a String ? What is the difference between using Object.prototype.toString.call(input) and using toString.call(input) ?
var isString = function (input) { // Почему здесь используют Object.prototype, // когда можно просто использовать метод toString.call(input) ? if (Object.prototype.toString.call(input) === '[object String]') { return true; } else { return false; } } console.log(isString('w3resource')); console.log(isString([0, 1, 2, 4])); console.log(isString({name: "Nureke", age: 24}));
typeofhere - Grundyif(typeof input == 'string') return true?true:false; else return false?true:false;- vp_arth