JSFiddle - React, Tailwind, and code Playground
by nerevar
HTML
<div class="log"></div>
CSS
.log {
font: 14px/20px Consolas, "Lucida Console", "DejaVu Sans Mono", "Courier New", Courier, monospace;
}
JavaScript
// log wrapper
var l = function(text) {
$('.log').append(text + "<br />");
}
l('using standart typeof:');
l('typeof 1 => ' + typeof 1);
l('typeof null => ' + typeof null);
l('typeof [] => ' + typeof []);
l('typeof function(){} => ' + typeof function(){});
// our cool method
Object.prototype.toType = function() {
return Object.prototype.toString.call(this).slice(8, -1).toLowerCase();
}
l('');
l('using object prototype:');
l('Date => ' + (new Date()).toType());
l(' => ' + [].toType());
l(' => ' + {}.toType());