JavaScript Introduction Terms Flashcards
Basic terms, defining variables, strings, booleans, operators, etc.
What is JavaScript?
It is a programming language that powers the dynamic behavior on most websites. Alongside HTML and CSS, it is a core technology that makes the web run.
What are Methods?
Methods return information about an object and are called by appending an instance with a period “.”, the method name, and parentheses. Example: Math.random(); // Returns a number between 0 and 1
What is a console.log()?
The console.log() method is used to log or print messages to the console. It can also be used to print objects and other info.
What is String Concatenation?
In JavaScript, multiple strings can be concatenated together using the “+” operator.
What is an Assignment Operator?
An assignment operator assigns a value to its left operand based on the value of its right operand.
What is the addition assignment operator?
+=
What is the subtraction assignment operator?
-=
What is the multiplication assignment operator?
*=
What is the division assignment operator?
/=
What is String Interpolation?
It is the process of evaluating string literals containing one or more placeholders (expressions, variables, etc). It can be performed using template literals: “text ${expression} text”. “‘Tommy is ${age} years old.’;”
What are Variables?
A variable is a container for data that is stored in computer memory. It is referenced by a descriptive name that a programmer can call to assign a specific value and retrieve it.
What does Undefined mean?
“undefined” is a primitive JavaScript value that represents lack of defined value. Variables that are declared but not initialized to a value will have the value “undefined”.
How do you declare a variable?
To declare a variable in JavaScript, any of these keywords can be used along with a variable name: var, let, and const.
When is the variable “var” used?
“var” is used in pre-ES6 versions of JavaScript.
When is the variable “let” used?
“let” is the preferred way to declare a variable when it can be reassigned. A “let” variable will contain “undefined” if nothing is assigned to it.
When is the variable “const” used?
“const” is the preferred way to declare a variable with a constant value. It must have an assignment. Any attempt of reassigning a “const” variable will result in a JavaScript runtime error.
What are Template Literals?
Template literals are strings that allow embedded expressions, for example: ${expression}. While regular strings use single ‘ or double “ quotes, template literals use backticks `` instead. Example: console.log(Hello, ${name}
);
What are Built-in Objects?
Built-in objects contain methods that can be called by appending the object name with a period “.”, the method name, and a set of parentheses. Example: Math.random(); // “Math” is the built-in object
What does String.length mean?
The “.length” property of a string returns the number of characters that make up the string. Example: console.log(‘howdy’.length); // Prints: 5
What are Booleans?
Booleans are a primitive data type. They can either be “true” or “false”. Example: let lateToWork = true;
What are Single Line Comments?
In JavaScript, single-line comments are created with two consecutive forward slashes //. Example: // This line will denote a comment
What does Null mean?
Null is a primitive data type. It represents the intentional absence of a value. In code, it is represented as “null”.
What are Strings?
Strings are a primitive data type. They are any grouping of characters (letters, spaces, numbers, or symbols) surrounded by single quotes ‘ or double “ quotes. Example: let single = ‘Where is my hat?’; or let double = “Where is my hat?”;
What is the Remainder / Modulo Operator?
The remainder operator, sometimes called modulo, returns the number that remains after the right-hand number divides into the left-hand number as many times as it evenly can. Example: const daysLeftOver = 365 % 7 ;