The toString method

The toString method is prototypically inherited by all the objects and wrapped objects (primitives). When you call this method on them, it returns a string token of the type. See the following examples:[]); // [object Array]{}); // [object Object]''); // [object String] Date()); // [object Date]// etc

Now you can use this to check the types, as shown by Todd Motto (

var getType = function (elem) { return, -1);};var isObject = function (elem) { return ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.