Greeting JavaScript: Hello World!6 min read

Undeniably, JavaScript is the most popular programming language according to Stack Overflow Survey 2018. As a consequence, it’s a great choice to start with this language. It runs almost every single webpage you’re currently visiting, easy to learn, not just front-end and also back-end development, mobile, desktop, game application, high in-demand in the job market, and more…These are the number of reasons why I talk about JavaScript. If you are a newbie and want to learn JavaScript, this series is right for you. We’ll cover from the very first steps with the easiest way to make things clear.

First, let’s define what is JavaScript? Don’t confuse between Java and JavaScript, they are 2 completely different programming languages.

In technobabble, JavaScript often abbreviated as JS, is a high-levelinterpreted programming language that conforms to the ECMAScript specification. It is a language that is also characterized as dynamicweakly typedprototype-based and multi-paradigm.

Most of the time, you can just think of JavaScript as a dynamically typed language and it supports multiple paradigms, meaning you don’t need to specify a type when you declare variable, function, etc…Multiple paradigms meaning you can use this language to write OOP code, but also other paradigms such as POP (Procedural Oriented Programming), or FP (Functional Programming).

Sounds confusing, but things will get more clear if you have time and play with it. 😅

Greeting in Browser Console

JavaScript is the programming language that has been designed to run mainly on the web browser. At first, IDEs are not necessary to run JavaScript files, you can write, run and debug your JavaScript on your own browser.

In order to open your browser’s console from Chrome, in Windows, open Chrome browser and type, ctrl+shift+i (On Mac is cmd+option+j).

When you open up the console, you will see something like this. Ignore everything else at this time, focusing on the console tab:

The environment that we have complete control over, but its contents don’t spill into the outside world – that’s why we use a console to handle stuff.


Now let’s try to do some cool stuff. In your console, type:

console.log("My very first line of code on JavaScript!");

As can be observed, the duty of console.log() is print out some outputs which is being wrapped in the parentheses to the console. It can be a string, a number, a function or an object, etc…(don’t worry about that, we will talk about it soon). You also can see the word undefined when you hit enter, it’s normal, don’t be freaking out.

Not only do we have console.log(), but we also have a lot of other console methods (A JavaScript method is a property containing a function definition – we’ll talk about property and function soon). But for now, I will just list 2 other frequently used console which are console.warn and console.error().


Now in your console type something similar to this:

console.warn("Be careful");

As the name of this, console.warn() method warns developers when they were trying to make a not wise decision and also plus a symbol and some yellow messages.


Likewise, in your console type:

console.error("This is not exactly an error, but I just did it for fun");

Just like console.warn(), but it is not a warn anyone. Instead, it displays an error with the red color and sometimes it will appear with the “stack trace” but not this case (don’t worry much about it right now.)


Now let’s do something a little cooler, say Hello World with a box that appears!

alert("Hello, World!");

Whoo-wee…an alert box just appeared in your window with some specified messages and an OK button. That is the function of the alert method.

Comment in JavaScript

What is a comment and why it is essential to our code?
Actually, a comment is something that we write in our code in order to make some notes of what’s going on, making source code easier for human understanding. Everything in a comment will be ignored by compilers and interpreters. In JavaScript, comment has the syntax like those:

// Just one to comment one line.
/* I want to write a comment more than 1 lines, so I write a 

comment like this, but I still have to write something else 

because I want it lasts a little more longer. */

Everything in the inside comment will not be displayed, for example:

Yeah, as you can see, nothing seems to appear (don’t care about undefined keyword.) Nevertheless, you still are able to use /* */in one line:

/* This is a comment */

But if you trying to make some notes in your source code without the syntax above, this will lead to an error:


From now on, you have a taste of JavaScript, what it is, console, comment…I will be back soon and we will talk about JavaScript syntax like Variable, Data Types, Array, Function…

Previous Article
Next Article
Every support is much appreciated ❤️

Buy Me a Coffee