Hello World
In a programing world, their is ritual which every new programer does. And i.e., write their very first Hello World program. So, lets get into it.
// This is a comment, and is ignored by the compiler
// You can test this code by clicking the "Run" button over there ->
console.log("Hello World");
NOTE: You can also edit the examples. Let see what happens when you change
Hello World
to your name and re-run the example.
Let's understand what is happening. The above code can be broken down into 3 parts.
console
It is one of the Global object, which provides us with methods to interact with console.
To open console just press Option + ⌘ + J
(on macOS), or Shift + CTRL + J
(on Windows/Linux). And re-run the code. You'll see Hello World
there as well.
We'll look this in detail when we start with object.
log
It is one the methods in the console
object, which let's write on console.
"Hello World"
It is called argument. An argument is a way for you to provide more information to a function.
And this argument of type string, one of the Primitive. Let's learn more about it.
Where else I can run JavaScript?
To run JavaScript, you need JavaScript Engine and every browsers have one.
I will tell you 3 places where you can run this code.
-
Terminal(recommended)