Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: logging methods should always be bound to console #27

Open
fitzgen opened this issue Mar 29, 2014 · 3 comments
Open

Proposal: logging methods should always be bound to console #27

fitzgen opened this issue Mar 29, 2014 · 3 comments

Comments

@fitzgen
Copy link
Contributor

fitzgen commented Mar 29, 2014

[1,2,3].forEach(console.log)

Expected Results:

logs 3 messages in the console

Actual Results:

Error: 'log' called on an object that does not implement interface Console.


This used to be the behavior in Firefox, but it recently broke. I've filed a bug to revert to the old behavior where the methods were always bound to console, but figured we should codify this behavior here too.

Its kind of masochistic to force developers to bind every time they pass console.log as an argument!

@fflorent
Copy link

I agree.

FWIW, your example works with Dragonfly (Opera 1.12.6) and Firebug (the latter binds the console methods to the console object). But it doesn't neither with Chrome DevTools.

Though I couldn't test with the WebInspector (if it differs from the Chrome DevTools) nor the IE DevTools.

Florent

@perpetual-hydrofoil
Copy link

I agree - I personally use this model all the time; for example, I'll often replace a callback function name with console.log during development (usually in Firebug). Writing a hand-off function is a big pain in the console. :)

@sindresorhus
Copy link

👍 It's very convenient when you want to log the output of a callback .catch(console.error) or create a shortcut const log = console.log. This is also how it works in Node.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants