logobj() : shows all properties, even things from prototypes (parents).
Useful for exploring native properties and functions on native js elements and objects.
console.clear();
log();
log(null);
log('');
log(0);
log('1');
log({a:1});
log([]);
log([1,"2",{c:3}]);
log(function (a,b){1;});
function fun1(c,d){2;}
log(fun1);
var fun2 = function(d,e){3;}
log(fun2);
log(document);
log(document.getElementById('br'));
// below might throw cross domain issues
// log(this);
// log(document.body);
// log(window);
function log(item) {
var properties = [], arr = [];
properties = log_get_item_properties(item);
properties.forEach(function(prop) {
arr.push({
prop : prop,
hasOwnProperty : item.hasOwnProperty(prop),
value_type : typeof item[prop],
value : item[prop],
value_tostring : ('' + item[prop]),
});
});
// max length 20char, compressed whitespace (and no linebreaks)
var item_description = ('' + item).replace(/\s+/g, ' ').substr(0, 50);
// group all results into one (collapsed) line:
console.groupCollapsed('log(' + item_description + ')');
// console.groupCollapsed('typeof item');
console.log('typeof item:', typeof item);
// console.groupEnd();
console.groupCollapsed('console.log(item)');
console.log(item);
console.groupEnd();
// in chrome an element in an array is often more clearly displayed,
// e.g. type (string or int etc.) is more clear to see.
console.groupCollapsed('console.log( [ item ] )');
console.log([item]);
console.groupEnd();
console.groupCollapsed('list of item properties');
console.log(properties);
console.groupEnd();
console.groupCollapsed('table of item properties and their values');
console.table(arr);
console.groupEnd();
console.groupEnd();
}
function log_get_item_properties(item) {
// For most values for (prop in item) is enough,
// but for (prop in item) does not seem to work on functions.
var properties = [];
if (typeof item === 'function') {
// Fill info for hardcoded list of known function properties:
// (source: in console, going over autocomplete items on "somefunction.")
var function_properties =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.