Cesar Jr Rodriguez Cesar Jr Rodriguez - 1 year ago 99
Javascript Question

Why console.log() and alert() functions are not actually part of Javascript?

Just that. Mozilla's Introduction to OOP in Javascript explains that

function isn't actually part of Javascript itself. So I'm very interested to know why these?

Answer Source

JavaScript is a language specification (strictly speaking, ECMAScript).

console, on the other hand, is an API. There are currently 669 Web APIs listed on MDN (to answer your second question). Same goes for window, for example.

Why isn't it part of JavaScript core? The same reason window isn't available to NodeJS (core) or process isn't available in the browser: these APIs are implemented by the environments within which JavaScript runs.

Similarly, why would you implement alert() in NodeJS, where there in no UI within which you could launch a modal with your message?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download