Lesson 2: Writing Simple Scripts Flashcards
What is each script known as?
A statement.
What should each statement end with?
A semi-colon ;
What are comments used for?
To explain what your code does.
Show a single line comment:
// single line comment
Show a multiple line comment:
/* multiple line comment */
What data types are there?
- Number : 3-5
- Boolean: true/false
- Undefined
- Null
What are variables used for?
To store information temporarily in order to complete certain tasks.
Declare a variable:
- vair quantity; // prior ES6
- let price; // variable
- const ratio; // constant
What type are Strings in JavaScript?
Primitive.
Use a string constructor to make a new string:
let str = new String(‘Hello’);
What does ‘Escaping’ mean?
Making a regular char after \ special and making a special char after \ literal.
Show escaping:
let question = ‘What/’s your name?’;
What does the string operator + symbol do?
Joins strings on either side of it.
Show concatenating strings:
let greeting = 'Hello'; let name = 'Bob' let message = greeting + name;
What are events?
The browser’s way of saying “Hey, this happened.”