Podcast
Questions and Answers
Which of the following is the correct way to include an external JavaScript file?
Which of the following is the correct way to include an external JavaScript file?
- <link rel="script" href="script.js">
- <javascript file="script.js"></javascript>
- <src="script.js"></script>
- <script src="script.js"></script> (correct)
Which of the following is NOT a component that a JavaScript statement may contain?
Which of the following is NOT a component that a JavaScript statement may contain?
- Operators
- Keywords
- Values
- Procedures (correct)
What is the purpose of the console.log()
function in JavaScript?
What is the purpose of the console.log()
function in JavaScript?
- To write content to an HTML element.
- To display a pop-up alert box.
- To execute an external script.
- To display content in the browser's JavaScript console. (correct)
In what year was JavaScript standardized as ECMAScript?
In what year was JavaScript standardized as ECMAScript?
Which of the following is the correct way to declare a variable in JavaScript?
Which of the following is the correct way to declare a variable in JavaScript?
What is one key characteristic of JavaScript?
What is one key characteristic of JavaScript?
Which keyword is used to define a function in JavaScript?
Which keyword is used to define a function in JavaScript?
If you add the number 5 to the string "10", what is the result in JavaScript?
If you add the number 5 to the string "10", what is the result in JavaScript?
What does the typeof
operator return?
What does the typeof
operator return?
What is a key characteristic of a loosely typed (or dynamically typed) language like JavaScript?
What is a key characteristic of a loosely typed (or dynamically typed) language like JavaScript?
JavaScript is an object-oriented programming language.
JavaScript is an object-oriented programming language.
Brendan Eich created JavaScript at Microsoft in 1995.
Brendan Eich created JavaScript at Microsoft in 1995.
JavaScript was originally named Mocha.
JavaScript was originally named Mocha.
JavaScript is directly related to Java.
JavaScript is directly related to Java.
Including JavaScript code in the <head>
section is always the best practice.
Including JavaScript code in the <head>
section is always the best practice.
JavaScript code in external files has a .html
extension.
JavaScript code in external files has a .html
extension.
The innerText
property inserts text into an HTML element.
The innerText
property inserts text into an HTML element.
JavaScript is case-insensitive.
JavaScript is case-insensitive.
A return statement will stop the execution of the function.
A return statement will stop the execution of the function.
Variables declared with const
cannot be reassigned.
Variables declared with const
cannot be reassigned.
Which of the following best describes a JavaScript object?
Which of the following best describes a JavaScript object?
Which of the following is an example of an object property?
Which of the following is an example of an object property?
What is the purpose of methods in a JavaScript object?
What is the purpose of methods in a JavaScript object?
Given let car = {brand: "Toyota"};
, how do you access the brand of the car?
Given let car = {brand: "Toyota"};
, how do you access the brand of the car?
What does it mean for JavaScript objects to be 'dynamic'?
What does it mean for JavaScript objects to be 'dynamic'?
Which of the following actions can you perform on a JavaScript object?
Which of the following actions can you perform on a JavaScript object?
Which of the following is a built-in JavaScript object?
Which of the following is a built-in JavaScript object?
Which of the following represents an array?
Which of the following represents an array?
What is the index of the first element in a JavaScript array?
What is the index of the first element in a JavaScript array?
Which JavaScript built-in object is used to work with dates and times?
Which JavaScript built-in object is used to work with dates and times?
In JavaScript, an object is a way to store multiple pieces of related data.
In JavaScript, an object is a way to store multiple pieces of related data.
Attributes of an object describe the actions it can perform.
Attributes of an object describe the actions it can perform.
Methods define the actions that an object can perform.
Methods define the actions that an object can perform.
A JavaScript variable can hold multiple values simultaneously, similar to an object.
A JavaScript variable can hold multiple values simultaneously, similar to an object.
Object properties can only be accessed using dot notation.
Object properties can only be accessed using dot notation.
JavaScript objects are static and cannot be extended once created.
JavaScript objects are static and cannot be extended once created.
The Math
object in JavaScript requires the new
keyword to be created.
The Math
object in JavaScript requires the new
keyword to be created.
Arrays in JavaScript can only store data of the same type.
Arrays in JavaScript can only store data of the same type.
Arrays in JavaScript are zero-indexed.
Arrays in JavaScript are zero-indexed.
The JavaScript Date
object can only represent the date, not the time.
The JavaScript Date
object can only represent the date, not the time.
What do control structures determine in a program?
What do control structures determine in a program?
What is the purpose of the else
keyword in an if
statement?
What is the purpose of the else
keyword in an if
statement?
Which statement is used to perform different actions based on different conditions?
Which statement is used to perform different actions based on different conditions?
In a switch
statement, what happens when a break
keyword is encountered?
In a switch
statement, what happens when a break
keyword is encountered?
What is the purpose of the default
case in a switch
statement?
What is the purpose of the default
case in a switch
statement?
What is a key component of a for
loop?
What is a key component of a for
loop?
What is an 'iteration' in the context of loops?
What is an 'iteration' in the context of loops?
What is the primary characteristic of a while
loop?
What is the primary characteristic of a while
loop?
How does a do...while
loop differ from a while
loop?
How does a do...while
loop differ from a while
loop?
Which keyword is used to exit a loop prematurely?
Which keyword is used to exit a loop prematurely?
Control structures determine the execution flow of a program.
Control structures determine the execution flow of a program.
The if
statement executes code regardless of the condition.
The if
statement executes code regardless of the condition.
In an if...else
statement, the else
block executes when the condition is true.
In an if...else
statement, the else
block executes when the condition is true.
A switch
statement is used to perform different actions based on different conditions.
A switch
statement is used to perform different actions based on different conditions.
The break
keyword in a switch
statement is optional and doesn't affect execution.
The break
keyword in a switch
statement is optional and doesn't affect execution.
A loop is a structure that executes a block of code once.
A loop is a structure that executes a block of code once.
In a for
loop, the initializer is executed after each iteration.
In a for
loop, the initializer is executed after each iteration.
While
loops and for
loops are post-test loops.
While
loops and for
loops are post-test loops.
A do...while
loop always executes its code block at least once.
A do...while
loop always executes its code block at least once.
The continue
statement exits a loop entirely.
The continue
statement exits a loop entirely.
What is the name for the hierarchical structure that the browser uses to organize web page components?
What is the name for the hierarchical structure that the browser uses to organize web page components?
Which object is at the top level of the DOM?
Which object is at the top level of the DOM?
The Window.screen.width
property provides what information?
The Window.screen.width
property provides what information?
Which property provides the color depth of the screen?
Which property provides the color depth of the screen?
Which method displays a simple alert message to the user?
Which method displays a simple alert message to the user?
Which method can be used to retrieve the title of the current document?
Which method can be used to retrieve the title of the current document?
What does the document.domain
property return?
What does the document.domain
property return?
Which method is best suited for modifying a specific element dynamically?
Which method is best suited for modifying a specific element dynamically?
Which of the following methods writes directly into the HTML document?
Which of the following methods writes directly into the HTML document?
Which property of a checkbox or radio button indicates whether it is selected?
Which property of a checkbox or radio button indicates whether it is selected?
The DOM is a hierarchical tree of web page components.
The DOM is a hierarchical tree of web page components.
The Window.screen.width
property returns the available screen width, excluding system UI elements.
The Window.screen.width
property returns the available screen width, excluding system UI elements.
A color depth of 8-bit allows for millions of colors.
A color depth of 8-bit allows for millions of colors.
JavaScript can display dialog messages using methods provided by the top-level DOM window object.
JavaScript can display dialog messages using methods provided by the top-level DOM window object.
The document.URL
property provides access to the page title.
The document.URL
property provides access to the page title.
document.domain
retrieves the domain name of the document.
document.domain
retrieves the domain name of the document.
document.forms.length
returns the number of forms in the document.
document.forms.length
returns the number of forms in the document.
Using index positions to access elements is the recommended modern approach.
Using index positions to access elements is the recommended modern approach.
The getElementsByClassArea
method is a valid way to reference HTML elements.
The getElementsByClassArea
method is a valid way to reference HTML elements.
The innerText property supports text and HTML elements.
The innerText property supports text and HTML elements.
Flashcards
What is JavaScript?
What is JavaScript?
A scripting language embedded in web browsers for client-side scripting.
What is ECMAScript?
What is ECMAScript?
The standard that JavaScript was standardized as in 1997.
What are Language Basics in JS?
What are Language Basics in JS?
Syntax, keywords, operators, and built-in objects.
How to include external JS file?
How to include external JS file?
Signup and view all the flashcards
What do JS statements contain?
What do JS statements contain?
Signup and view all the flashcards
What are keywords?
What are keywords?
Signup and view all the flashcards
What are operators?
What are operators?
Signup and view all the flashcards
What are data types in JavaScript?
What are data types in JavaScript?
Signup and view all the flashcards
What is a variable?
What is a variable?
Signup and view all the flashcards
What is a function?
What is a function?
Signup and view all the flashcards
Why use JavaScript?
Why use JavaScript?
Signup and view all the flashcards
How to include JavaScript?
How to include JavaScript?
Signup and view all the flashcards
What are values in JS?
What are values in JS?
Signup and view all the flashcards
What are Expressions?
What are Expressions?
Signup and view all the flashcards
What is a JS statement?
What is a JS statement?
Signup and view all the flashcards
What is whitespace in JS?
What is whitespace in JS?
Signup and view all the flashcards
Why use external JS files?
Why use external JS files?
Signup and view all the flashcards
let vs. const?
let vs. const?
Signup and view all the flashcards
Ways to write output?
Ways to write output?
Signup and view all the flashcards
What is scope in JS?
What is scope in JS?
Signup and view all the flashcards
What is an Object?
What is an Object?
Signup and view all the flashcards
What are Attributes (Properties)?
What are Attributes (Properties)?
Signup and view all the flashcards
What are Behaviors (Methods)?
What are Behaviors (Methods)?
Signup and view all the flashcards
Why Use Objects?
Why Use Objects?
Signup and view all the flashcards
Dot Notation
Dot Notation
Signup and view all the flashcards
Bracket Notation
Bracket Notation
Signup and view all the flashcards
Are JavaScript Objects dynamic?
Are JavaScript Objects dynamic?
Signup and view all the flashcards
List of Built-in Objects
List of Built-in Objects
Signup and view all the flashcards
What is an Array?
What is an Array?
Signup and view all the flashcards
What does the Date Object represent?
What does the Date Object represent?
Signup and view all the flashcards
What are Object Attributes?
What are Object Attributes?
Signup and view all the flashcards
What are Object Behaviors?
What are Object Behaviors?
Signup and view all the flashcards
What is a JavaScript Array?
What is a JavaScript Array?
Signup and view all the flashcards
What is Dot Notation?
What is Dot Notation?
Signup and view all the flashcards
What is Bracket Notation?
What is Bracket Notation?
Signup and view all the flashcards
When to use 'new'?
When to use 'new'?
Signup and view all the flashcards
getFullYear()
getFullYear()
Signup and view all the flashcards
getMonth()
getMonth()
Signup and view all the flashcards
getDate()
getDate()
Signup and view all the flashcards
Control Structures
Control Structures
Signup and view all the flashcards
"If" Statement
"If" Statement
Signup and view all the flashcards
"Else" Statement
"Else" Statement
Signup and view all the flashcards
"Switch" Statement
"Switch" Statement
Signup and view all the flashcards
"For" Loop
"For" Loop
Signup and view all the flashcards
"While" Loop
"While" Loop
Signup and view all the flashcards
"Do While" Loop
"Do While" Loop
Signup and view all the flashcards
"Break" Keyword
"Break" Keyword
Signup and view all the flashcards
"Continue" Statement
"Continue" Statement
Signup and view all the flashcards
What are Control Structures?
What are Control Structures?
Signup and view all the flashcards
What is the 'else' statement?
What is the 'else' statement?
Signup and view all the flashcards
What is a 'do while' loop?
What is a 'do while' loop?
Signup and view all the flashcards
What is the 'default' statement in a switch?
What is the 'default' statement in a switch?
Signup and view all the flashcards
What is a loop structure?
What is a loop structure?
Signup and view all the flashcards
What is a loop initializer?
What is a loop initializer?
Signup and view all the flashcards
What is a loop condition?
What is a loop condition?
Signup and view all the flashcards
What is a loop modifier?
What is a loop modifier?
Signup and view all the flashcards
What is the Document Object Model (DOM)?
What is the Document Object Model (DOM)?
Signup and view all the flashcards
Why is the DOM Important?
Why is the DOM Important?
Signup and view all the flashcards
What is the screen child object?
What is the screen child object?
Signup and view all the flashcards
What is Window.screen.width?
What is Window.screen.width?
Signup and view all the flashcards
What is Window.screen.height?
What is Window.screen.height?
Signup and view all the flashcards
What is Window.screen.availWidth?
What is Window.screen.availWidth?
Signup and view all the flashcards
What is Window.screen.availHeight?
What is Window.screen.availHeight?
Signup and view all the flashcards
What is Window.screen.colorDepth?
What is Window.screen.colorDepth?
Signup and view all the flashcards
What does window.alert(message) do?
What does window.alert(message) do?
Signup and view all the flashcards
What does window.confirm(message) do?
What does window.confirm(message) do?
Signup and view all the flashcards
What does window.prompt(message, defaultValue) do?
What does window.prompt(message, defaultValue) do?
Signup and view all the flashcards
What are forms, images, links, styleSheets, and scripts?
What are forms, images, links, styleSheets, and scripts?
Signup and view all the flashcards
How to access element by ID?
How to access element by ID?
Signup and view all the flashcards
How to access element by tag name?
How to access element by tag name?
Signup and view all the flashcards
How to access element by class name?
How to access element by class name?
Signup and view all the flashcards
What is innerHTML?
What is innerHTML?
Signup and view all the flashcards
What is innerText?
What is innerText?
Signup and view all the flashcards
setAttribute()
setAttribute()
Signup and view all the flashcards
What are Event-handlers?
What are Event-handlers?
Signup and view all the flashcards
Study Notes
Meet DOM
- A browser organises webpage elements into a hierarchical tree structure.
- In this structure, the Document Object Model (DOM), each element is nested under the window object.
Inspect Properties
- The
screen
object, a child of thewindow
object, holds properties defining the user's monitor resolution, in pixels.
Access Elements
- Accessing elements via Javascript methods is favourable over array indexing.
- Array indexing is error-prone when HTML is modified, is tedious in large documents, and is more complex.
Events
- Responding to events involves the event itself triggering a defined function.
- Events are handled via HTML Event Attributes for inline use or through JavaScript's
addEventListener
for event registration on specific targets.
Load Events
- Load events trigger after a page has fully loaded, prompting functions to execute.
Check Boxes and Radio Buttons
- Checkboxes allow multiple selections, while radio buttons, grouped with shared names, allow only one selection.
- Both elements use a
.checked
property to reflect their selected state.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.