JSFiddle - React, Tailwind, and code Playground

by amatiasq

HTML

<script src="http://amatiasq.com/fiddle-console.js"></script>

JavaScript

function Constructor(param) {
    return param;
}

[
    [ 'Object', {} ],
    [ 'Array', [] ],
    [ 'String', 'testing' ],
    [ 'Number', 5 ],
    [ 'Boolean', true ],
    [ 'Null', null ]
].forEach(function(item) {
    var name = item[0];
    var value = item[1];
    var returned = new Constructor(value);
    var proto = Object.getPrototypeOf(returned);
    
    console.log(name, 'returned', returned);
    console.log(name, 'typeof', typeof returned);
    console.log(name, 'constructor', getCtorName(returned));    
    console.log(name, 'isPrototyped', proto === Constructor.prototype);
    console.log(name, 'instanceof', returned instanceof Constructor);
    console.log('');
});


function getCtorName(object) {
    return object.constructor.name;
}