Posts

JavaScript Fundamentals

Hello, world! This part of the tutorial is about core JavaScript, the language itself. Later on, you’ll learn about Node.js and other platforms that use it. But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We’ll keep the amount of browser-specific commands (like  alert ) to a minimum so that you don’t spend time on them if you plan to concentrate on another environment (like Node.js). We’ll focus on JavaScript in the browser in the  next part  of the tutorial. So first, let’s see how we attach a script to a webpage. For server-side environments (like Node.js), you can execute the script with a command like  "node my.js" . The “script” tag JavaScript programs can be inserted into any part of an HTML document with the help of the  <script>  tag. For instance: <!DOCTYPE HTML> <html> <body>    <p>Before the script...</p>     <script&g

An Introduction to JavaScript

Let’s see what’s so special about JavaScript, what we can achieve with it, and which other technologies play well with it. What is JavaScript? JavaScript was initially created to “make web pages alive” . The programs in this language are called scripts . They can be written right in a web page’s HTML and run automatically as the page loads. Scripts are provided and executed as plain text. They don’t need special preparation or compilation to run. In this aspect, JavaScript is very different from another language called Java . Why JavaScript? When JavaScript was created, it initially had another name: “LiveScript”. But Java was very popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help. But as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript , and now it has no relation to Java at all. Today, JavaScript can execute not only in the browser, but al