Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

JavaScript Basics for Beginners — Simple Steps to Create Your First Program

JavaScript is the most popular programming language in the world, as well as the programming language of the Web itself. What’s probably even more important for beginners, however, is that JavaScript is one of the easiest programming languages to learn and get into.

Granted, mastering JavaScript to its fullest potential still takes time and is tricky in some respects, but learning the basics and getting relatively proficient with it is surprisingly quick – so much so that even kids can get into it quite easily!

How to Get Started

Learning to code is one of those things that is best learned by doing. There will still be a fair bit of reading and watching involved, but that should usually be done alongside your own initial attempts. So, here are the first thing you should do to start.

Set Up Your Computer

JavaScript is the only programming language out there that works directly on a browser. This means that you don’t really need to install any additional software to start – you can just run it on your browser. Different browser have different key commands for opening a JavaScript console, but here are some of the most common ones:

  • Google Chrome (on Windows): Ctrl + Shift + J
  • Google Chrome (on Mac): Cmd + Opt + J
  • Mozilla Firefox (on Windows): Ctr + Shift + K
  • Mozilla Firefox (on Mac): Cmd + Opt + K
  • Microsoft Edge (on Windows): Settings + More (…) + More Details + Developer Tools + Console tab
  • Microsoft Edge (on Mac): Cmd + Opt + J

Once you open the JavaScript console on your browser, you can start coding directly on it. Of course, for more complex coding tasks, it’s usually best to get a more intricate software. Editors, such as Sublime, Webstorm, VS Code, and others can be used for free to code on JavaScrip too. However, for creating your first program, it’s enough to just open up your browser.

Get the Right Resources

As you’re getting ready to start, you should also make sure that you have the right learning materials with you. Fortunately, there is no need for heavy text books, as there are plenty of convenient learning tools and course online. Courses, such as CodeMonkey.com are very convenient to get into and learn from for adults and children alike. Going through a quick and simple course like CodeMonkey and making your first coding attempts alongside it is the easiest way to learn the basics.

Learn JavaScript Code Structure

Once you’ve got everything ready, you can start with your first steps — learning the three basics of JavaScript code structure:

Statements

Statements are the simplest type of commands in JavaScript – they are singular instructions you give for your computer to run. Statements always end with a semicolon (;), similar to how most sentences in a human language end with a dot.

For example, the statement let bestColor; instructs the system to create a let variable name “bestColor”.

Comments

Comments in JavaScript are additional instructions meant to add context. A comment in JavaScript is any line of code that starts with two forward slashes (//). The system always ignores comments when it reads the code, so they can be used to disable code without deleting it or to leave notes for yourself or other coders.

For example, this is a statement:

console.log("I am learning JavaScript");

But this is a comment:

// console.log("I am learning JavaScript");`

Execution Flow

The execution flow of statements in JavaScript is always top-down, meaning that the first line of statements will be executed before the second, then the third, and so on.

Reserved Keywords

These words are the “letters” of the language that is JavaScript. They are the commands that instruct the system to do certain things. Reserved Keywords, such as console, const, function, return, for, if, while and others always have specific meanings inside JavaScript and can’t be used for anything else other than what they are intended to. Learning these reserved keywords is as important to understanding JavaScript as learning the alphabet is important to learning English.

Variables

Unlike reserved keywords, which are constants in JavaScripts, variables are labels you can create yourself within the code. These are your own custom terms that you can attach value to and teach the system to remember them and associate them with said value. This way, when you want to refer to the same value later on, you can use the variable and the system will understand what you mean.

These first few basics are at the core of understanding JavaScript. As soon as you learn the main reserved keywords, you can write your first statements for JavaScript to execute!

Like this article?

Buy me a coffee

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?