programming-examples/js/String/Check whether an 'input' is a string or not.js

8 lines
279 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
is_string = function(input) {
if (Object.prototype.toString.call(input) === '[object String]')
return true;
else
return false;
};
console.log(is_string('w3resource'));
console.log(is_string([1, 2, 4, 0]));