console
is not included in the list, but is pretty much available to use in any environment.
On a side note, why isn't console
capitalized like every other built-in global object like Number
or Array
?
console
is not included in the list, but is pretty much available to use in any environment.
On a side note, why isn't console
capitalized like every other built-in global object like Number
or Array
?
ECMA-262 doesn't define console
because ECMA-262 has no concept of I/O. Simply each browser implements/injects its own console
implementation.
The console object was first introduced by browser debugging tools, Firebug was the first to try to formulate a consistent standard for the console api.
The WHATWG (Web Hypertext Application Technology Working Group) has an early work in progress console
spec to define the semantics of the console APIs, in an attempt to create convergence across environments.
console
is not included in the list, but is pretty much available to use in any environment.
The console
object is somehow consistent between browsers due to the following:
Browsers and Node.js all individually follow the WHATWG console spec.
Chrome extends WebKit which is also used by Safari.
Node.js is built on top of V8, which defines the console API used by node.
Currently many of the console
methods are cross-browser compatible, however this was not always the case. Check the compatibility table to see the differences.
Arguably, each console
implementation differs based on the environment it is served in, (chips, servers, browsers, etc.). Hence it does not make complete sense to have it standardized in ECMA.
Just like other browser specific APIs, the console
is injected to javascript to give developers access to the browser API, such as Node
and Document
.
Here is a list of the complete web API injected into javascript to be accessible in JS code on the browser.
why isn't
console
capitalized like every other built-in global object?
All methods provided by the whatwg spec implementing the window
interface are not capitalized (Check the window interface), Since non of those methods are constructor functions.
It is also mentioned in the spec that the console
is lowercased due to historical reasons. However this note is talking about the namespace definition using "console" instead of "Console" used in the spec and NOT the exposed API.
FUN FACT: I remember the time when the console
used to throw an error if the debugger was not opened on IE.
console
because ECMA-262 has no concept of I/O. 2) browsers and node all individually follow the whatwg console spec, not by browsers happening to be built on other browsers as you suggest. 3) whatwg console spec is already ratified, so no need to use future tense "will be part of the whatwg spec"
console
implementations of the different environments converged before it became a whatwg standard - either because implementations inherited from each other or because they followed the standard set by the Firebug extension (unfortunately no longer online). Here's a bit of history overview: 2ality.com/2013/10/console-api.html
console
is lowercased."console
because it's not a constructor function. But since you've drawn my attention to your elaboration, "All methods provided by the whatwg spec implementing the window interface are not capitalized" is not an explanation, since, as I've already had to note above,console
is not a method.window.console
is the namespace they're talking about. It is an object whose sole purpose is to group various console-related methods. They are not two different things, as you imply in 'This note is for the namespace definition using "console" and not "Console", not the exposed api on thewindow
object'.