<<

Lesson: Web Programming(4) Omid Jafarinezhad

Sharif University of Technology ● HTTP, JavaScript, CSS, HTML5, ReactJs, Flow, Progressive Web App

● Golang, NodeJs, MongoDB, PostgreSQL, Redis

● Docker, Git, NPM, YUIDoc, Materials Jest, , Gulp, , Locust

● (Optional/Research) Kubernetes, InfluxDB, RabbitMQ, gRPC, Ansible JavaScript

JavaScript was initially created to “make webpages alive”. ● An introduction ● JavaScript Fundamentals ● Code quality ● Objects: the basics ● Data types The JavaScript ● Advanced working with functions ● Objects, classes, inheritance ● Error handling language ● Document ● Introduction into Events Materials ● Events in details ● Forms, controls ● Animation ● Frames and windows ● Regular expressions ● Promises, async/await An Introduction to JavaScript

When JavaScript was created, it initially had another name: “LiveScript”. But language 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

At present, JavaScript can execute not only in the browser, but also on the server, or actually on any device where there exists a special program called the JavaScript engine JavaScript engine

The browser has an embedded engine, sometimes it’s also called a “JavaScript virtual machine”

Different engines have different “codenames”, for example:

● V8 – in Chrome and ● SpiderMonkey – in ● …There are other codenames like “Trident”, “Chakra” for different versions of IE, “ChakraCore” for , “Nitro” and “SquirrelFish” for etc How engines work?

Engines are complicated. But the basics are easy

1. The engine (embedded if it’s a browser) reads (“parses”) the script 2. Then it converts (“compiles”) the script to the machine language 3. And then the machine code runs, pretty fast What makes JavaScript unique?

Full integration with HTML/CSS

Simple things done simply

Supported by all major browsers and enabled by default Languages “over” JavaScript recently a plethora of new languages appeared, which are transpiled (converted) to JavaScript before they run in the browser. Examples of such languages:

● CoffeeScript is a “syntax sugar” for JavaScript, it introduces shorter syntax, allowing to write more precise and clear code. Usually Ruby devs like it. TypeScript is concentrated on adding “strict data typing”, to simplify development and support of complex systems. It is developed by Microsoft ● Dart is a standalone language that has its own engine that runs in non-browser environments (like mobile apps). It was initially offered by Google as a replacement for JavaScript, but as of now, browsers require it to be transpiled to JavaScript just like the ones above Code editors

● IntelliJ editors: WebStorm ● Visual Studio ● -based products, like and ● Komodo IDE and its lightweight free version ● Netbeans ● (cross-platform, free) ● (cross-platform, free) ○ Nuclide (facebook open source) ● (cross-platform, shareware) ● Notepad++ (Windows, free)

Create a hello world project!

1. Create a project 2. Init git 3. Init npm

Hello, world!

JavaScript programs can be inserted in any part of an HTML document with the help of the

Web Analytics