An Introduction Flashcards

1
Q

How is JS different than Java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How was JS named?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

EcmaScript

A

JavaScript became a fully independent language with its own specification called ECMAScript, and now it has no relation to Java at all.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JS Engine

A

JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does JS work on browser work then?

A

The browser has an embedded engine sometimes called a “JavaScript virtual machine”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Different Engine Names

A

V8 – in Chrome and Opera.

SpiderMonkey – in Firefox.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do Engines work?

A

Engines are complicated. But the basics are easy.

The engine (embedded if it’s a browser) reads (“parses”) the script.
Then it converts (“compiles”) the script to the machine language.
And then the machine code runs, pretty fast.

The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and further optimizes the machine code based on that knowledge.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why is Javascript safe?

A

It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JS capabilities

A

JavaScript’s capabilities greatly depend on the environment it’s running in. For instance, Node.js supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What can In-browser js do?

A

Add new HTML to the page, change the existing content, modify styles.
React to user actions, run on mouse clicks, pointer movements, key presses.
Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).
Get and set cookies, ask questions to the visitor, show messages.
Remember the data on the client-side (“local storage”).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What cant in-browser JS do?

JS - LImitation 1

A

JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS functions.

Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like “dropping” a file into a browser window or selecting it via an tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

JS- Lim 2

A

Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites (from a different domain, protocol or port).

This is called the “Same Origin Policy”. To work around that, both pages must agree for data exchange and contain a special JavaScript code that handles it. We’ll cover that in the tutorial.

This limitation is, again, for the user’s safety. A page from http://anysite.com which a user has opened must not be able to access another browser tab with the URL http://gmail.com and steal information from there.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

JS - Lim 3

A

JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that’s a safety limitation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What makes JS unique?

A

Full integration with HTML/CSS.
Simple things are done simply.
Support by all major browsers and enabled by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Transpilation

A

Languages are transpiled (converted) to JavaScript before they run in the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

CoffeeScript

A

shorter syntax

Ruby devs like it.

17
Q

TypeScript

A

is concentrated on adding “strict data typing” to simplify the development and support of complex systems. It is developed by Microsoft.

18
Q

Flow

A

Flow also adds data typing, but in a different way. Developed by Facebook.

19
Q

Dart

A

Dart is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.

20
Q

Brython

A

Brython is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.

21
Q

Manuals and Specifications

A

https: //www.ecma-international.org/publications-and-standards/standards/ecma-262/
https: //tc39.es/ecma262/

22
Q

EcmaScript Documentation

A

The ECMA-262 specification contains the most in-depth, detailed and formalized information about JavaScript. It defines the language.

But being that formalized, it’s difficult to understand at first. So if you need the most trustworthy source of information about the language details, the specification is the right place. But it’s not for everyday use.

23
Q

MDN (Mozilla) JavaScript Reference

A

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference.

it’s often best to use an internet search instead. Just use “MDN [term]” in the query, e.g. https://google.com/search?q=MDN+parseInt to search for parseInt function.

24
Q

Compatibility tables

A

JavaScript is a developing language, new features get added regularly.

To see their support among browser-based and other engines, see:

http: //caniuse.com – per-feature tables of support, e.g. to see which engines support modern cryptography functions: http://caniuse.com/#feat=cryptography.
https: //kangax.github.io/compat-table – a table with language features and engines that support those or don’t support.

25
Q

IDEs

A

Visual Studio Code (cross-platform, free).
WebStorm (cross-platform, paid).
For Windows, there’s also “Visual Studio”, not to be confused with “Visual Studio Code”. “Visual Studio” is a paid and mighty Windows-only editor, well-suited for the .NET platform. It’s also good at JavaScript. There’s also a free version Visual Studio Community.

26
Q

Other Code Editors

A

Atom (cross-platform, free).
Visual Studio Code (cross-platform, free).
Sublime Text (cross-platform, shareware).
Notepad++ (Windows, free).
Vim and Emacs are also cool if you know how to use them.

27
Q

Developer Console

A

F12

cmd + opt + J (for MAC users)