Node.js – console.log does not show items in array but instead shows [Object]

It looks like this is an old topic, anyway I’ve faced the same issue, embedded array printed as [Array]. It is because of console.log in the node.js uses util.inspect for print, the default depth is 2. So, to print something which is deeper than 2 followings can be used: const util = require(‘util’) console.log(util.inspect(errors, true, … Read more

How to disable console.log messages based on criteria from specific javascript source (method, file) or message contents

Preamble The beginning discusses how stuff works in general. If you just care for the code, skip Introduction and scroll to the Solution heading. Introduction Problem: there is a lot of console noise in a web application. A significant amount of that noise is coming from third party code which we do not have access … Read more

Dumping whole array: console.log and console.dir output “… NUM more items]”

Setting maxArrayLength There are a few methods all of which require setting maxArrayLength which otherwise defaults to 100. Provide the override as an option to console.dir console.dir(myArry, {‘maxArrayLength’: null}); Set util.inspect.defaultOptions.maxArrayLength = null; which will impact all calls to console.log and util.format Call util.inspect yourself with options. const util = require(‘util’) console.log(util.inspect(array, { maxArrayLength: null … Read more

Access function location programmatically

The answer, for now, is no. The [[FunctionLocation]] property you see in Inspector is added in V8Debugger::internalProperties() in the debugger’s C++ code, which uses another C++ function V8Debugger::functionLocation() to gather information about the function. functionLocation() then uses a number of V8-specific C++ APIs such as v8::Function::GetScriptLineNumber() and GetScriptColumnNumber() to find out the exact information. All … Read more

console.log(myFunction()) returns undefined

In JavaScript, if nothing is returned from the function with the keyword return then undefined is returned by default. var data = greet(); console.log(data);// undefined, since your function does not return. Is equivalent to: console.log(greet()); The second output is the returned result from the function. Since you are not returning anything from the function hence … Read more

Restoring console.log()

Since original console is in window.console object, try restoring window.console from iframe: var i = document.createElement(‘iframe’); i.style.display = ‘none’; document.body.appendChild(i); window.console = i.contentWindow.console; // with Chrome 60+ don’t remove the child node // i.parentNode.removeChild(i); Works for me on Chrome 14.