Hello world
js
console.log('Hello world')There are many concepts in this simple line:
consoleis an object of the environment: it is not defined in the language (in the ECMAScript standard). It allows displaying what is given to it as arguments: either in the browser console (for browsers), or in the standard output for node.js, Deno, Bun and other JavaScript/TypeScript runtimes;logis a property of theconsoleobject;logis a function;- In JavaScript, a function is an object, with a superpower: it is invocable (the specification refers to it as a callable object);
logis called (also referred to as invoked) as a method on theconsoleobject;'Hello world'is an argument passed to theconsole.logfunction, which accepts an almost infinite number of parameters;console.logis a function that displays in the "dev tools" console (Developer Tools) the content of the arguments passed to it: here, "Hello world" will be displayed in the console;- Note: the dot syntax found in Java and Python to access a property of an object.