Javascript Flashcards
What is a console?
The console is a panel that displays important messages, like errors, for developers. If we want to see things appear on our screen, we can print, or log, to our console directly.
console.log()
When we write console.log() what we put inside the parentheses will get printed, or logged, to the console. This is important so we can see the work that we’re doing.
What are the two types of code comments in Javascript?
A single line comment and a multi-line comment
How do you write a single line comment?
// + comment
Note: You can also write a single line comment after a line of code.
How do you write a multi-line comment?
/* to begin the comment, and / to end the comment.
Note: you can also use this syntax to comment something out in the middle of a line of code.
Ex: console.log(/IGNORED!*/ 5); // Still just prints 5
When is it a good time to use multi-line comments?
When preventing a block of code from running.
What are data types? How many fundamental data types are there?
Data types are the classifications we give to the different kinds of data that we use in programming. There are 7 fundamental data types.
What are the seven different fundamental data types?
Number, string, boolean, null, undefined, symbol, and object.
What is a string data type?
Any grouping of characters on your keyboard (letters, numbers, spaces, symbols, etc.) surrounded by single quotes: ‘ … ‘ or double quotes “ … “
What is a boolean data type?
A data type that only has two possible values- true or false. You can think of it as answers to a “yes” or “no” question.
What is a null data type?
This data type represents the intentional absence of a value, and is represented by the keyword null
What is an undefined data type?
Uses the keyword undefined (without quotes) and means that a given value does not exist. It represents the absence of a value like null but is used differently.
What is an object data type?
Collections of related data.
What is an operator?
An operator is a character that performs a task in our code.
Examples:
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
What is the keyboard symbol for the multiply operator?
- Ex: 7 * 3 = 21
What is the keyboard symbol for the division operator?
/
Ex: 9/3 = 3
What is the keyboard symbol for the remainder operator?
%
console.log(11 % 3); // Prints 2
What is the remainder operator sometimes called?
modulo
What is string concatenation?
Combining one string to another string use the + operator.
Ex: console.log(‘hi’ + ‘ya’); // Prints ‘hiya’
How would we include space in between two strings when we are using string concatenation?
We have to include empty parenthesis in between them or space at the end or beginning of a string.
Ex:
console.log(‘front ‘ + ‘space’);
// Prints ‘front space’
console.log(‘back’ + ‘ space’);
// Prints ‘back space’
console.log(‘no’ + ‘space’);
// Prints ‘nospace’
console.log(‘middle’ + ‘ ‘ + ‘space’);
// Prints ‘middle space’
What are properties?
Properties are the values associated with a JavaScript object.
What is the symbol used for the dot operator?
.
Ex: console.log(‘Hello’.length); // Prints 5
What are methods?
A method is a function that belongs to some object or a set of some instructions that performs a certain task.
How do we use or “call” methods?
We call, or use, methods by attaching an instance with:
a period (the dot operator)
the name of the method
opening and closing parentheses
Ex:’example string’.methodName().
Ex: console.log(‘hello’.toUpperCase()); // Prints ‘HELLO’