To begin with a little background information. All programming languages are divided into compiled and interpreted. To run a program written in a compiled language, the code must first be run through a compiler. But the code in a interpreted language does not need to be run – passed to the interpreter, and it immediately executes it.

JavaScript refers to the second type of language. On the one hand, it’s convenient – less hassle and routine, more creativity. On the other hand – without an interpreter it simply will not run. Fortunately, all modern web browsers are friendly with JavaScript.

Here’s how to run a script in your browser:

Take the code.
Paste it into the browser.
And that’s it.
That sounds easy. Let’s write something. Open the browser console (Ctrl + Shift + J or Cmd + Opt + J) and paste in this code:

var userName=prompt(“What’s your name?)

confirm(“Hi, ” + userName + “!)
Enter your name and click OK. Now the site knows how to say hello to us!

Let’s take a more complicated task. Let’s say your music teacher has an anniversary, and you’re preparing a small postcard site for him as a gift. Added a beautiful inscription, pictures, poems. It seems to be all there is, but something is missing – well, right, balloons! That’s not right. Take this code and paste it into the console:

var js = document.createElement(‘script’);
js.src = “https://safronovmax.github.io/LoveCursor/birthday.js”;
document.body.appendChild(js);

Wham – and you’re the storm of the Internet, the stray web emperor of the noughties. And the balloons will disappear on their own, in ten seconds – you can keep reading articles.