Introduction
JavaScript is one of the most popular programming languages on the planet. It can both be used as a client-side or server-side language. On the client-side, it is used with HTML(Hypertext Markup Language) and CSS(Cascading Style Sheets) to enhance a web page’s functionality such as: validating forms, creating interactive maps, and displaying animated charts. JavaScript can also be run on servers; a popular server side environment is Node.js. Here, it's used to access databases and file systems.
Getting Started
Because of its wide range of applications, you can run JavaScript in several ways:
- Using console tab of web browsers
- Using Node.js
- Using code editors e.g. Visual Studio Code
- By creating web pages
All the popular web browsers have built-in JavaScript engines hence you can run JavaScript on a browser. In this JavaScript guide we'll be using the google chrome console tab to run our first JavaScript program.
The first step is to open google chrome, followed by opening the console tab by pressing Ctrl+Shift+i
if you're on windows. You can use the console tab to run any JavaScript program.
In JavaScript, users can declare a variable using 3 keywords: var, let and const. var is global scoped, let is block scoped while const is also block scoped but can't be updated once it's declared.
Our first JavaScript program will simply be outputting a message on the console. Let's first declare a string variable x as shown below.
var x = "Hello world!";
The next step is to output the string on the console using the command below.
console.log(x);
The output of this program is shown below.
What Next?
If you wish to continue learning JavaScript in depth, here are some free resources that may be helpful:
I hope you found this article useful and I'd like to urge you to do as many projects as possible in order to improve your skills. Bonne chance!
Top comments (0)