Learn Javascript

Introduction

What is Javascript?

JavaScript is the programming language of the web. It is very easy to learn and is used in all sorts of applications including websites, mobile apps, cars and robots. It’s a very flexible language which allows it to do a lot of different things but sometimes means people decide to extend it to do specific things faster.

Should I learn JavaScript?

Absolutely, it will be the best programming decision you’ve ever made. It’s used everywhere.

Is JavaScript easy to learn?

As JavaScript is so popular there is a huge support community and countless resources to help you learn in the best way for you – from slow but cheap online courses through to fast bootcamp style learning. However you choose to learn, practice.

Can I learn JavaScript without HTML and CSS?

Absolutely, some professional JavaScript developers don’t even know HTML or CSS. It will be a benefit for sure, but some backend roles don’t require any of those skills.

The basics of JavaScript programming

Programming languages are how humans tell computers what they want them to do. They are an expression of logic, business rules and instructions, written in a fixed way that the computer can understand. We call this syntax.

Different programming languages have different syntax. One of the most popular languages in the world is called JavaScript. It’s used on web pages, robotics, even cars! Its popularity is ever-growing because of its ability to run on any computer and any operating system.

Getting Started

In order to run your first JavaScript program, you need a runtime. This runtime takes your instructions and converts them into code that your computer can understand. All modern web browsers have a runtime built in, allowing you to run JavaScript code on websites.

There are various websites that can run JavaScript code for you. One of which is JS Console

Open up the JS Console editor and type in

alert(‘Hello World’);

When you press enter, you should find a popup saying ‘Hello World’. Congratulations, you’ve run your first computer program!

Note – if this doesn’t work for you, make sure you type the code in exactly as written. Accuracy is key! Computers aren’t forgiving when it comes to interpreting instructions.

Let’s break down what’s happening.

The word alert in our program is called a function. In code, functions are 1 or more instructions grouped together with a name. I like to think of them a bit like a recipe. In this case, alert is a function that’s built into JavaScript. It alerts a message onto the screen.

After the word alert we have some brackets. All functions have brackets (sometimes called parentheses) which contain any inputs the function needs to run. Think of our recipe mentioned earlier, we might want to give our recipe an input of how many people to make a cake for. Our function might look like this:

makeCake(5);

This would imply a function that makes a cake for 5 people.

In our program, the alert function takes a single inputich is the message to display on the screen. In our case, ‘Hello World’. As we are passing text, we have to surround the text with quotes so that JavaScript knows it is dealing with text rather than code.

Challenge

There is a JavaScript function called console.log – use this function, passing in an input of your name. What do you see?

This is just scratching the surface of JavaScript. Join us at our next taster day to learn how to use JavaScript, HTML and CSS to build a computer game in less than three hours.

Free Taster Days

Come and learn to code a web app, and get a glimpse into the day in the life of a _nologist. We’re a friendly bunch here: with plenty of professional advice to share with anyone curious about the job potential of learning to code. Join us at one of our free taster days in Bristol or London.

Become a developer in 12 weeks

Inspired by a career in technology? So are we. Sign up to learn more about joining our 12-week tech training course. Book a call, and introduce yourself to the _nology team today!