Podcast
Questions and Answers
What is the JavaScript code to alert the remainder when 15 is divided by 9?
What is the JavaScript code to alert the remainder when 15 is divided by 9?
alert(15 % 9);
What assignment operator will result in x being 15 if x = 10 and y = 5?
What assignment operator will result in x being 15 if x = 10 and y = 5?
x += y;
What assignment operator will result in x being 50 if x = 10 and y = 5?
What assignment operator will result in x being 50 if x = 10 and y = 5?
x *= y;
What is the data type of the variable 'length' in the following code? let length = 16; // Number
What is the data type of the variable 'length' in the following code? let length = 16; // Number
What event makes an element turn red when someone moves the mouse over it?
What event makes an element turn red when someone moves the mouse over it?
How do you escape characters to alert 'We are Vikings'?
How do you escape characters to alert 'We are Vikings'?
What method would you use to convert text into uppercase?
What method would you use to convert text into uppercase?
What JavaScript method is used to replace 'Hello' with 'Welcome' in a string?
What JavaScript method is used to replace 'Hello' with 'Welcome' in a string?
What does ESLint help with?
What does ESLint help with?
What does Prettier do?
What does Prettier do?
What symbol is used for a single-line comment in JavaScript?
What symbol is used for a single-line comment in JavaScript?
Where do you want to place a script tag in an HTML document?
Where do you want to place a script tag in an HTML document?
What does it mean when we say JavaScript is an object-oriented language?
What does it mean when we say JavaScript is an object-oriented language?
What happens to the website when you write code in the browser console?
What happens to the website when you write code in the browser console?
What is the natural environment for JavaScript?
What is the natural environment for JavaScript?
What is ECMAScript?
What is ECMAScript?
What is default behavior in JavaScript?
What is default behavior in JavaScript?
What does the 'async' keyword do?
What does the 'async' keyword do?
What does the 'defer' keyword do?
What does the 'defer' keyword do?
How do you load modules in JavaScript?
How do you load modules in JavaScript?
When does the browser execute JavaScript?
When does the browser execute JavaScript?
What are methods in JavaScript?
What are methods in JavaScript?
What is an object in JavaScript?
What is an object in JavaScript?
What are properties in JavaScript?
What are properties in JavaScript?
What does 'this' refer to in JavaScript?
What does 'this' refer to in JavaScript?
What is a constant in JavaScript?
What is a constant in JavaScript?
What does console.log do?
What does console.log do?
How do you access object properties?
How do you access object properties?
What does bracket notation allow?
What does bracket notation allow?
What is a parameter in JavaScript?
What is a parameter in JavaScript?
What is a class in JavaScript?
What is a class in JavaScript?
What is a class declaration in JavaScript?
What is a class declaration in JavaScript?
What is a class expression in JavaScript?
What is a class expression in JavaScript?
What does the constructor method do?
What does the constructor method do?
What is the difference between class and object constructor functions?
What is the difference between class and object constructor functions?
How do you get the current date and convert it into a string?
How do you get the current date and convert it into a string?
How do you find the age of an object in JavaScript?
How do you find the age of an object in JavaScript?
How do you access the property named in a variable in JavaScript?
How do you access the property named in a variable in JavaScript?
What is the code in the second line of an object called?
What is the code in the second line of an object called?
Why is it best practice to place objects inside constants?
Why is it best practice to place objects inside constants?
Which object property names are not valid?
Which object property names are not valid?
How do you access an object in JavaScript?
How do you access an object in JavaScript?
Can an object created from a class be given the same name as the class?
Can an object created from a class be given the same name as the class?
How do you define an object in JavaScript?
How do you define an object in JavaScript?
Where do you find official documentation for built-in objects?
Where do you find official documentation for built-in objects?
How do you create a new object from a class?
How do you create a new object from a class?
What is the established convention for formatting objects?
What is the established convention for formatting objects?
What is the difference between a function and a method?
What is the difference between a function and a method?
Can you use arrow functions to create object methods?
Can you use arrow functions to create object methods?
When creating a class, are prototype methods added inside the constructor method?
When creating a class, are prototype methods added inside the constructor method?
What is a template literal in JavaScript?
What is a template literal in JavaScript?
How to show the value of everydayPack.name?
How to show the value of everydayPack.name?
How do you declare a JavaScript expression inside a template literal?
How do you declare a JavaScript expression inside a template literal?
How do you select the main element using query selector?
How do you select the main element using query selector?
How to select the last name in the list using query selector?
How to select the last name in the list using query selector?
How do you change all list items in the list to red?
How do you change all list items in the list to red?
How do you find the class name of an h1 element?
How do you find the class name of an h1 element?
How do you change the class name of an h1 element?
How do you change the class name of an h1 element?
How do you add a new class using query selector?
How do you add a new class using query selector?
How do you remove a class using query selector?
How do you remove a class using query selector?
How do you replace a class using query selector?
How do you replace a class using query selector?
When should you use className?
When should you use className?
How to select the style of the .site-title?
How to select the style of the .site-title?
How to select the color of the .site-title?
How to select the color of the .site-title?
How to change the color of the .site-title?
How to change the color of the .site-title?
How to get the property name of a style in .site-title?
How to get the property name of a style in .site-title?
How to create a new element and append it to your document?
How to create a new element and append it to your document?
How to create a new element for a nav menu?
How to create a new element for a nav menu?
What method(s) would you use to check if an element has a specific ID?
What method(s) would you use to check if an element has a specific ID?
What is the difference between element.className and element.classList?
What is the difference between element.className and element.classList?
What does the HTML markup of a new img element look like after the given script executes?
What does the HTML markup of a new img element look like after the given script executes?
What is the value of const target after this code executes?
What is the value of const target after this code executes?
What is the value after executing const target = document.getElementsByClassName('.note');?
What is the value after executing const target = document.getElementsByClassName('.note');?
What kind of selectors do querySelector and querySelectorAll use?
What kind of selectors do querySelector and querySelectorAll use?
What happens if you run this code: target.style.font-family = 'sans-serif';?
What happens if you run this code: target.style.font-family = 'sans-serif';?
What does the element.classList.toggle() method do?
What does the element.classList.toggle() method do?
Where does the new element appear when using document.createElement?
Where does the new element appear when using document.createElement?
What is the 'DOM'?
What is the 'DOM'?
How do you add an element created using createElement() to the DOM?
How do you add an element created using createElement() to the DOM?
What is a variable in JavaScript?
What is a variable in JavaScript?
In the expression var name = piggy, what is 'piggy'?
In the expression var name = piggy, what is 'piggy'?
What does 'let' do in JavaScript?
What does 'let' do in JavaScript?
When should you use 'const'?
When should you use 'const'?
How to find the type of a variable in JavaScript?
How to find the type of a variable in JavaScript?
What is the difference between assignment and comparison operators?
What is the difference between assignment and comparison operators?
What is absolute equivalence in JavaScript?
What is absolute equivalence in JavaScript?
How do you express 'a' to the power of 'b'?
How do you express 'a' to the power of 'b'?
How do you increment a number before or after output?
How do you increment a number before or after output?
What does a single equals symbol in JavaScript indicate?
What does a single equals symbol in JavaScript indicate?
What happens if you use a named variable without first declaring it?
What happens if you use a named variable without first declaring it?
What is the value of defaultColor after executing provided code?
What is the value of defaultColor after executing provided code?
How do you capture the result of a math equation like 42 * 38 in JavaScript?
How do you capture the result of a math equation like 42 * 38 in JavaScript?
How do you create a function to display 'Hello' in the inner HTML of an element with the ID 'demo'?
How do you create a function to display 'Hello' in the inner HTML of an element with the ID 'demo'?
In what scenario should you use var instead of let?
In what scenario should you use var instead of let?
Which statement is true?
Which statement is true?
Study Notes
JavaScript Basics
alert(15%9);
alerts the remainder when 15 is divided by 9.x += y;
is an assignment operator resulting inx
being 15, equivalent tox = x + y
.x *= y;
assigns 50 tox
, same asx = x * y
.
Data Types and Variables
- Use comments to document:
let length = 16; // Number
let lastName = "Johnson"; // string
const x = { firstName: "John", lastName: "Doe" }; // object
onmouseover
triggers when the mouse hovers over an element.- Escape characters allow for double quotes in strings:
We are \"Vikings\"
.
String Methods
- Convert text to uppercase using
toUpperCase()
. - Replace substrings using:
let txt = "Hello World"; txt = txt.replace("Hello", "Welcome");
Code Quality Tools
- ESLint: detects coding errors and requires Node.js.
- Prettier: formats code cleanly and also requires Node.js.
Commenting
- Single line comment syntax:
//
- Multi-line comment syntax:
/* comment here */
.
JavaScript Execution
- Script tags are generally placed within the head for initial loading.
- JavaScript is object-oriented, modeled around objects with properties and methods.
- Browser console code affects only the current session and is lost upon refresh.
ECMAScript and Browser Behavior
- ECMAScript: specification for JavaScript's implementation in browsers.
- Default JavaScript behavior can block rendering until execution is complete (content blocking).
async
downloads scripts in parallel with HTML, whiledefer
ensures scripts only execute after HTML parsing completion.
Object-Oriented Programming
- To create and use classes in JavaScript, declare with
class ClassName {}
. - Constructors define properties and methods for class instances.
- Methods are functions within objects; functions are standalone.
Working With Objects
- Object properties are accessed using dot notation (e.g.,
backpack.name
) or bracket notation (e.g.,backpack["pocketNum"]
). - Constants hold values that cannot be reassigned after initialization.
- A variable created from a class cannot have the same name as the class itself to avoid conflicts.
The Document Object Model (DOM)
- DOM represents the structure of an HTML document as objects; can be manipulated using methods like
document.createElement()
. - Use
document.querySelector()
to select elements using CSS selectors. - Element manipulation involves adding, removing, or replacing classes and elements through properties like
classList
.
Creating and Modifying Elements
- To create and append new elements:
const newArticle = document.createElement("article"); main.append(newArticle);
- Use
appendChild()
orinsertAdjacentElement()
to add elements to the DOM.
Data Types and Operators
- Use
typeof
to determine variable types. - Assignment vs comparison:
=
for assignment,==
for equality check,===
for strict equality. - Increment numbers with
++a
ora++
.
Array Manipulation
- Add items to an array with
collection[collection.length] = "new item"
orbackpackContents.push("pencil", 5)
.
Best Practices
- Keep object definitions within constants to prevent unintentional alterations.
- Use
let
orconst
for variable declarations to ensure scope is maintained. - Object properties in constants can be modified but the reference itself cannot be changed.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge of JavaScript through interactive flashcards. Each card covers essential concepts such as operators, alerts, and comments. Perfect for students looking to strengthen their programming skills in JavaScript.