what is console.log() how it’s working internally
why does it matter? I wouldn’t be focusing on it. Making computers as smart as they are today, took million of manhours. Certain things are best not to get into, at least not in the beginning. I know, it sucks. Certain things are better left as a blackbox, some magic that works under the hood
The short version is that the
console is something which is built-in to browsers (and the codecademy exercises).
.log() is a method of console object, which logs information to the console.
you can read about the console here:
if you really want to. Just now that
.log() can be used to log information to it (the console)
I know this post is a little late (ok, very late), but…
While it doesn’t seem related to your question, the selected answer has a quite easily understandable explanation:
It stores the logged values then displays them on the screen. How it works exactly would be quite hard to find out (you would have to spend a bit of time finding the correct code. For those who are experienced scanning open-source code it might be easier). It also depends on the browser you are using (different browsers implement console methods in different ways). A good example would be having a div on your webpage and making your own “output function”. When your function is called it adds elements to the div on the webpage with the values passed into your function, kind of like how console adds to the console box when you call it. This is more or less an analogy, so don’t expect things that may work with the example to work with console.log.
Like another reply said here, computers have gotten quite complex and smart today. How they do it could be more complex then the example I gave you. It also uses something called “eager evaluation” (it evaluates what you put into console.log then posts it. Therefore
console.log(window.alert("")) works because it evaluates the window.alert` first then logs the return value). If this seems complex, then congrats: you have successfully entered the lower level concepts of how a programming language works.
Long story short: it displays whatever you log to it on a little box called the console. How it works is more complex and handled differently with different browsers.