JavaScript Overview Flashcards
What is a program?
A set of instructions for a computer to carry out.
We write programs to solve a specific problem or provide a specific experience. The skill of programming, therefore, has two steps: first, programming is finding solutions to problems; second, programming is implementing those solutions in a particular programming language so your computer can understand and execute your solution.
What is JavaScript?
JavaScript (JS) is a programming language available in all modern browsers. JS is an implementation of the ECMAScript standard.
We can use the JS programming language, which ECMA determines, to control the engine in a browser. The better you understand the programming language, the better you control the engine.
What is ECMA?
ECMA controls the standard for JavaScript programming language, which is called ECMAScript. All web browsers should have a JavaScript version that is ECMA compliant. Each web browser is responsible for interpreting the ECMAScript.
What is DOM API?
Document Object Model API
The part of JavaScript that deals with interacting with HTML elements. It’s specified by the W3C (World Wide Web Consortium), which is the same organization that creates the specification for HTML.
What is Chrome DevTools?
Chrome DevTools provides an interactive JavaScript console where you can run and debug code.
How do you open Chrome DevTools on a MAC?
Option + ⌘ + J
How do you open Chrome DevTools on a PC?
Ctrl + Shift + J
What is a variable?
A variable is a name that is attached to a value. Variables are used to create and represent data in our applications. (Variables are data in our apps.)
How does a variable work?
When you need to create data, you create a keyword. Use the var, let, or const keywords to create the data. Then you enter how you want the JS to represent the piece data it’s grabbing:
var someIdentifier
Then you give it an assignment operator:
var someIdentifier = ‘somevalue’;
So here we are telling it to grab this piece of memory (var) with this label (someIdentifier) and set it equal to this value (somevalue).
You can also write it in this way with an undeclared variable:
var someIdentifier;
someIdentifier = somevalue;
What is a constant?
A constant cannot be reassigned with a new value. It’s used to define constant values, which is another way of saying variables whose value cannot be reassigned.
You can declare it in JS by entering “const”:
const someIdentifier = ‘somevaluethatwon’teverchange’
The defining feature of a constant is that its value cannot be changed, and the browser enforces this behavior. When you try to change the value of a constant, you’ll get an error.
In JavaScript, what are the 3 commands we can use to declare space in memory where we’ll store values?
var
let
const
In JavaScript, what does the equal sign (=) mean?
Assignment operator
What is let or var?
These are used to define variables with values that can (but don’t have to) be changed or reassigned.
How can you declare a variable without an assignment operator? What does this do?
var someIdentifier;
When you declare a variable without an assignment operator, it has no value yet.
What value does JavaScript give declared but unassigned variables?
undefined
What are two rules for naming variables?
Reserved words: You can’t use reserved words in a variable name. For example, you can’t reassign the name var to a new rule like this:
var var = ‘some value’;
However, you can use a reserved word as part of a name though it might be redundant:
var varFoo;
Character restrictions: A variable name must begin with an upper or lower case letter, $, or _. It cannot begin with a number. Spaces cannot appear anywhere in the variable name. Comparison and logical operators cannot be used in variable names. So these are unacceptable:
let my Foo = ‘bar’;
let my+Foo;
Numbers can appear in a variable name, so this is acceptable:
let myFoo2;