Preparations Flashcards

1
Q

What is a runtime environment?

A

It is an execution environment that lets an application program access system resources and provides the tools the application needs to operate.

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

What is a runtime environment in simple words?

A

It turns an application from a set of instructions into something that performs actual work.

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

What is a programming language?

A

A programming language is a set of syntactic and semantic rules that describe a formal language and must be able to express the steps that a machine needs to perform to convert some input to an output.

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

Before the computer can perform those steps, what does it need to happen?

A

The program needs to be converted to a form the computer can understand.

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

What programs do we need for this conversion?

A

Compilers and interpreters.

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

What do compilers and interpreters do?

A

At their most basic level, compilers and interpreters are similar: they both translate a program written in a specific programming language to something that the computer can execute, typically referred to as “1s and 0s” since all information on digital computers gets stored as 1s and 0s.

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

How do compilers and interpreters differ?

A

They differ primarily in what they do with those 1s and 0s.

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

What do compilers do?

A

Compilers produce an output file that the computer can run directly, perhaps after some additional processing called linking.

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

What do interpreters do?

A

Interpreters, however, don’t produce 1s and 0s that the computer can run directly - instead, the interpreter runs the interpreted code directly, or perhaps passes it on to a companion program.

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

Is JavaScript an interpreted language?

A

YES!

However, for performance reasons, most modern JavaScript engines employ a special kind of compiler called a Just In Time (JIT) compiler that takes the interpreted code one step further and lets the computer run the result.

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

What does an Application Programming Interface (API) do?

A

When an application accesses an operating system’s resources, something must ensure that the operating system provides them in a regulated and safe manner.
The API provides that functionality.

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

What does an API do in other terms?

A

It describes the scheme and format that a programmer can use to securely access resources, with the operating system acting as an intermediary.

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

What does a runtime environment do?

A

A runtime environment typically adds another layer of abstraction on top of the operating system’s API to make these resources available with a higher-level (i.e., more accessible) API.

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

What is a runtime environment composed of?

A

The compiler/interpreter and the operating system’s APIs together make up a runtime environment.

In other words, they provide the tools that an application needs to run.

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

What is a development environment?

A

A runtime environment with debugging and profiling tools.

For our purposes, we’ll treat the developer tools as part of the runtime environment.

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

What are the two major runtime environments in JavaScript?

A

The browser and Node.js.

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

What is the browser?

A

The web browser was the original JavaScript runtime environment, and it’s still the most dominant.

JavaScript running in the browser is far more ubiquitous than JavaScript running anywhere else.

Almost every browser has a JavaScript engine built into it.

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

What are the two main purposed of the browser?

A

1) to programmatically alter web pages based on user actions.

2) to exchange messages with a server over a network.

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

What does the programmer need to alter web pages?

A

The programmer needs an API through which they can manipulate the structure and appearance of the HTML page.

The DOM (Document Object Model) API lets you manipulate the structure and appearance of a web page

20
Q

What does the programmer need to exchange messages with a server over a network?

A

The XHR (XMLHttpRequest) interface and the Fetch API let you communicate with a server.

21
Q

Do browsers have developer tools?

A

All major browsers provide a “Developer Tools” feature that includes a REPL, a debugger, a network inspector, a performance profiler, and more.

22
Q

What is Node.js?

A

Node.js is a runtime environment that turns JavaScript into a general-purpose programming language that can run applications on almost any system.

23
Q

What is Node.js composed of?

A

The creators of Node.js took the open-source Chrome V8 JavaScript engine and added APIs and tools required for desktop and server computing.

It also provides an interactive REPL (read-eval-print loop) where you can execute JavaScript commands and get instant results.

24
Q

What capabilities does a general-purpose programming language (like Node.js) require?

A
  1. The ability to read and write disk files (disk I/O)
  2. The ability to read and write via the terminal (standard I/O)
  3. The ability to send and receive messages over a network (network I/O)
  4. The ability to interact with a database.
25
Q

What is a code editor used for?

A

A code editor is used to create plain text documents with no styling or formatting.

26
Q

How do I use the semicolons?

A

Use semicolons to terminate each logical line of code unless the line ends with {, }, or :

27
Q

When should I use camelCase?

A

Use camelCase formatting for most variable and function names.

28
Q

When should I use PascalCase?

A

Constructor functions

29
Q

When should I use uppercase names with underscores (SCREAMING_SNAKE_CASE)?

A
  1. To represent constants that serve as unchanging configuration values in your program.
  2. TO represent so-called magic numbers (which may not actually be numbers) – constants that are important to your program in some way but not as configuration values. For instance:
30
Q

What are the simple commands in the command line?

A
31
Q

What is a REPL?

A

A REPL (read-eval-print loop) for a programming language is an interactive environment where you can type commands and expressions in that language and get immediate results. Node.js comes with one such REPL, which you access with the node command:

32
Q

Should you test code in ‘node’?

A

YES!

With the REPL, it’s easy to confirm whether some code works as you expect, and it can help you figure out how to fix the command if it doesn’t work.

33
Q

What do you type to exit the console and go back to the command line?

A

Press “control-c” twice, or press “control-d” once.

34
Q

How can you run JavaScript files from the command line?

A

Once you create a JavaScript file, one with a .js extension, you can run the code in that file by typing the node command followed by the file name.

35
Q

What happens when you run a JavaScript file from the command line, the code gets executed by something called an interpreter?

A

The code gets executed by something called an interpreter: it takes JavaScript code and turns it into code that your computer understands.

36
Q

What do you write to exit a program?

A

“control + c”

37
Q

How do you run code from a file in a browser?

A
  1. You must first embed the code in an HTML file
  2. Add a script tag to the HTML file that has the path to your .js file in the src attribute.
  3. Save the HTML file, then open it in a browser. You should see a blank page in your browser. To see the JavaScript output, you must visit the console, which we’ll describe in the next section.
38
Q

What is another way to run code from a file in a browser?

A

It is to write all your JavaScript between the opening and closing

 tags: don't use a .js file at all.
39
Q

What does a programming environment provide?

A

A programming environment provides two main types of reusable code to an application:

1) components and operations that are part of the core language, often collectively referred to as the standard library.

2) components and operations specific to a runtime environment.

40
Q

What are constructors?

A

Factories that create values of a particular type

41
Q

What are methods in JavaScript?

A

Methods are functions that need a value that you can use to call the function.

42
Q

How many types of methods are there?

A

There are two types of methods:

  1. Instance methods
  2. Static methods
43
Q

What format do you use to call instance methods?

A

Constructor.prototype.methodName()

44
Q

What format do you use to call static methods?

A

Constructor.methodName()

45
Q

As well as operations, what do some data types have?

A

Properties

A data type’s property is a noun; an operation is a verb.

A property name says something about the value and an operation does something with that value.

46
Q

What do you apply instance methods to?

A

To a value of the type that the constructor represents.

47
Q

How do you call static methods?

A

You use the constructor name (String) instead of a value