JavaScript is a lightweight, cross-platform, object-oriented computer programming language. Lightweight just means that the language doesn’t use much memory of the computer, and that it has a relatively simple syntax and features. Cross-platform just means that the language can be used on multiple platforms and systems. Оbject-oriented means that it’s a language that’s based on object.
Тogether with HTML and CSS, JavaScript is one of the three core technologies of web development. This language is commonly used as a client language in web browsers, but lately it can be put to use in the so called back end, setting up web application, servers or even in cross-platform mobile applications.
With this language we can create simple websites, or more complex web based web applications.
What do we need to get started with JavaScript?
First of all you need some kind of tool for writing your code. You can use any kind of text editor, from stock text editor that comes with your OS, or you can download some free, and more advanced editors, like Brackets. You can also consider using some tool for code writing like Visual Studi Code, where you can add some plug ins that will ease your work, like syntax checks, grammar checks, colorizing of the code. Below you have a link to some text editors:
Notepad++: https://notepad-plus-plus.org/
Brackets: http://brackets.io/
Visual Studio Code: https://code.visualstudio.com/?wt.mc_id=DX_841432
How to prepare JavaScript project?
It is very simple to start a JavaScript project that will run in browser. Firs we need to create new folder anywhere we like. Then we will need some files in it. First file that we will need, to show our javaScript code that it is working, we need to create index.html file inside our project folder. The structure of this file is shown below:
1 2 3 4 5 6 7 8 9 10 11 12 |
<html lang="en"> <head> <meta charset="UTF-8"> <title>Section 2: JavaScript Language Basics</title> </head> <body> <h1>Section 2: JavaScript Language Basics</h1> </body> <script src="home.js"></script> </html> |
In here we have tag <script> where we put our javaScript files to run. Here we need to create home.js where .js file extension represent javaScript file, and the browser knows how to run in. Below we have an example of javaScript code:
1 2 3 4 5 6 7 8 9 10 11 12 |
console.log('Hello world'); // Expression var number = 3 + 5; // Statement var someThing = 5; var otherThing = 1; if(someThing > otherThing) { console.log('Executing some statement'); }; |
And thats it. Just double click on previously created index.html and the browser will open. Of course nothing will be visible on screen, but when you open the browser console (F12 for Chrome, CTRL+SHIFT+K for Mozilla), and you will see on the console that Hello World text is logged.