How do I learn the JavaScript programming language on the Mac?

So you want to learn JavaScript? That's a good idea! JavaScript is the most popular programming languages around, topping Stack Overflow's 2015 developer survey with 54.4 percent of programmers using it. And it works well on Mac, too.

Read next: Complete guide to coding and programming on a Mac

If you're looking to learn to program, then JavaScript is a great choice. Unlike Python or C, it's a scripting language and works in conjunction with other technologies. You'll use JavaScript alongside HTML and CSS to create interactive elements for websites.

JavaScript is one of the first programming languages you should learn. It follows on quickly from HTML and CSS, and you learn the fundamentals of programming while quickly creating impressing websites that show off your new-found skills.

See also:

Macworld Secrets: What is HTML 5?

Learn how to code in Java on a Mac

How to set up and learn Python coding on a Mac

Learn JavaScript in OS X: Setting up JavaScript

JavaScript is an interpreted language. You don't compile JavaScript programs and run them (in the sense that you do in C). Instead, you write code and attach it inside HTML (the language used to display content on websites).

Like HTML, the requirements for writing JavaScript programs are simple. You need a text editor and a web browser. Safari is fine as a web browser, but we don't advise creating code in TextEdit because it doesn't save as text files.

Here are some programs you should consider if you're going to learn JavaScript (and web development in general).

It's a good idea to install the Firebug extension for Firefox. Lots of JavaScript developers use the Firebox extension to inspect HTML and modify the code in real time. You won't need it at first, but it'll come in handy as you progress.

Create Hello world in JavaScript

It's traditional to create your first program to display "Hello, World!" on the screen. Displaying the words is even easier in HTML, but this JavaScript program (inside a HTML file) creates an alert on the screen, displaying "Hello World":

Open your text editor and enter the following code:

How to learn JavaScript in Mac OS X

Save this file to your desktop as "helloworld.html". Now drag the file on top of the Safari icon in your Dock (or open Safari and choose File > Open File).

When the browser reads the HTML document, it'll interpret the JavaScript code and run the program. You place JavaScript code inside HTML using the  tags.

Hello World in Javascript on a Mac

Learning Javascript on your Mac

Now that you have the basic equipment set-up, it's time to start learning JavaScript. Because JavaScript works so closely with HTML, you'll need to learn HTML and CSS alongside JavaScript.

Here are some courses to look at:

  • Codecademy: JavaScript track. The online tutorials at Codecademy walk you from being a complete beginner, up to create highly complex sites.
  • Learn JavaScript in 12 minutes. This YouTube video does a great job of explaining the basics of JavaScript in the advertised timespan.
  • JavaScript 24-hour Trainer. This book is a more in-depth tour of the JavaScript language. Reading this will help you get to grips with the language.
  • Professional JavaScript for Web Developers. Now that you know the basics of the language, this book takes you into the world of web development.
  • JavaScript Patterns. This book takes you into professional development. It looks at the best way to create JavaScript applications, and the patterns to look for in good code.