Podcast
Questions and Answers
What is a defining feature of variables declared with const?
What is a defining feature of variables declared with const?
- They have block scope. (correct)
- They can be reassigned later.
- They can be redeclared multiple times.
- They must have a global scope.
How can a property of a JavaScript object be accessed?
How can a property of a JavaScript object be accessed?
- By calling objectName[propertyName] method.
- Invoking objectName.propertyName() function.
- Using the method objectName->propertyName.
- Using objectName.propertyName or objectName['propertyName'] (correct)
What does the function toCelsius(fahrenheit) do?
What does the function toCelsius(fahrenheit) do?
- Returns the input temperature as is.
- Calculates the freezing point of water.
- Converts Fahrenheit to Celsius. (correct)
- Converts Celsius to Fahrenheit.
Which of the following statements about JavaScript objects is false?
Which of the following statements about JavaScript objects is false?
What result does person.fullName() return?
What result does person.fullName() return?
What is true regarding HTML events?
What is true regarding HTML events?
Which method correctly calls an object method?
Which method correctly calls an object method?
Which of the following is NOT a characteristic of const variables?
Which of the following is NOT a characteristic of const variables?
In JavaScript, an object allows for the grouping of which of the following?
In JavaScript, an object allows for the grouping of which of the following?
To access the last name of a person stored in an object, which of the following syntaxes is correct?
To access the last name of a person stored in an object, which of the following syntaxes is correct?
What does the slice() method do when a second parameter is omitted?
What does the slice() method do when a second parameter is omitted?
What is the output of the code: let part = str.slice(-12); where str is 'Apple, Banana, Kiwi'?
What is the output of the code: let part = str.slice(-12); where str is 'Apple, Banana, Kiwi'?
How does substr() differ from slice() in terms of the second parameter?
How does substr() differ from slice() in terms of the second parameter?
What will the following code output: let part = str.substr(-4); where str is 'Apple, Banana, Kiwi'?
What will the following code output: let part = str.substr(-4); where str is 'Apple, Banana, Kiwi'?
What is a key characteristic of the replace() method?
What is a key characteristic of the replace() method?
If str is 'Apple, Banana, Kiwi', what will str.slice(7, 13) return?
If str is 'Apple, Banana, Kiwi', what will str.slice(7, 13) return?
What happens if the first parameter of slice() is negative?
What happens if the first parameter of slice() is negative?
What will be the output of the following code: let part = str.substr(7, 6); if str is 'Apple, Banana, Kiwi'?
What will be the output of the following code: let part = str.substr(7, 6); if str is 'Apple, Banana, Kiwi'?
What is the result of calling str.replace('a', 'o') on the string 'Apple, Banana, Kiwi'?
What is the result of calling str.replace('a', 'o') on the string 'Apple, Banana, Kiwi'?
What does the slice() method return if both parameters are negative, e.g., str.slice(-5, -1)?
What does the slice() method return if both parameters are negative, e.g., str.slice(-5, -1)?
What will be the output of the following code: let text = 'MSA students and MSA staff!'; let newText = text.replace('MSA', 'CS'); console.log(newText);?
What will be the output of the following code: let text = 'MSA students and MSA staff!'; let newText = text.replace('MSA', 'CS'); console.log(newText);?
Which of the following statements correctly uses the concat() method?
Which of the following statements correctly uses the concat() method?
What does the toUpperCase() method do?
What does the toUpperCase() method do?
What is the purpose of the trim() method in string manipulation?
What is the purpose of the trim() method in string manipulation?
In which scenario would you use the split() method?
In which scenario would you use the split() method?
How would you correctly call the toLowerCase() method on a string variable text1?
How would you correctly call the toLowerCase() method on a string variable text1?
What does the output of the following code produce: let text1 = ' welcome!'; let text2 = text1.trim(); console.log(text2);?
What does the output of the following code produce: let text1 = ' welcome!'; let text2 = text1.trim(); console.log(text2);?
What is expected when using the split() method with a pipe character as the delimiter, given the string 'a|b|c|d|e|f'?
What is expected when using the split() method with a pipe character as the delimiter, given the string 'a|b|c|d|e|f'?
Which method would you use to remove whitespace only from the start of a string?
Which method would you use to remove whitespace only from the start of a string?
If the below code is executed, what will be the value of myArray? let text = 'a b c d e f'; const myArray = text.split(' ');
If the below code is executed, what will be the value of myArray? let text = 'a b c d e f'; const myArray = text.split(' ');
What does the 'onchange' event signify in HTML?
What does the 'onchange' event signify in HTML?
Which of the following is NOT a valid HTML event?
Which of the following is NOT a valid HTML event?
Which method is used to determine the length of a string in JavaScript?
Which method is used to determine the length of a string in JavaScript?
What does the 'substr(start, length)' function do in JavaScript?
What does the 'substr(start, length)' function do in JavaScript?
What will the following code return: let text = 'Hello'; text[1];
?
What will the following code return: let text = 'Hello'; text[1];
?
Which of the following correctly uses template literals for variable substitution?
Which of the following correctly uses template literals for variable substitution?
Which event should you use to execute a function after a page has finished loading?
Which event should you use to execute a function after a page has finished loading?
What will the output of the following code be: let greeting = 'Hello World'; console.log(greeting.slice(0, 5));
?
What will the output of the following code be: let greeting = 'Hello World'; console.log(greeting.slice(0, 5));
?
Which string declaration is correct in JavaScript?
Which string declaration is correct in JavaScript?
Flashcards
Constant Variables (const)
Constant Variables (const)
Variables declared with const
cannot be redeclared or reassigned. They have block scope, meaning they are only accessible within the block where they are defined.
JavaScript Functions
JavaScript Functions
A block of code designed to perform a specific task, executed when called (invoked).
JavaScript Objects
JavaScript Objects
Flexible collections of key-value pairs, grouping related data (properties) and functions (methods).
Accessing Object Properties
Accessing Object Properties
Signup and view all the flashcards
Object Methods
Object Methods
Signup and view all the flashcards
HTML Events
HTML Events
Signup and view all the flashcards
String
String
Signup and view all the flashcards
String Length Property
String Length Property
Signup and view all the flashcards
onchange event
onchange event
Signup and view all the flashcards
HTML Button
HTML Button
Signup and view all the flashcards
onclick event
onclick event
Signup and view all the flashcards
onload event
onload event
Signup and view all the flashcards
onmouseover event
onmouseover event
Signup and view all the flashcards
onmouseout event
onmouseout event
Signup and view all the flashcards
onkeydown event
onkeydown event
Signup and view all the flashcards
String.slice()
String.slice()
Signup and view all the flashcards
String.slice() parameters
String.slice() parameters
Signup and view all the flashcards
String.slice() negative indices
String.slice() negative indices
Signup and view all the flashcards
String.substr()
String.substr()
Signup and view all the flashcards
String.substr() omitting the second parameter
String.substr() omitting the second parameter
Signup and view all the flashcards
String.substr() negative index
String.substr() negative index
Signup and view all the flashcards
String.replace()
String.replace()
Signup and view all the flashcards
String.replace() first match
String.replace() first match
Signup and view all the flashcards
String.replace() case sensitivity
String.replace() case sensitivity
Signup and view all the flashcards
What is the purpose of replace()
in JavaScript?
What is the purpose of replace()
in JavaScript?
Signup and view all the flashcards
What is the concat()
method used for in JavaScript?
What is the concat()
method used for in JavaScript?
Signup and view all the flashcards
How do you convert a string to uppercase in JavaScript?
How do you convert a string to uppercase in JavaScript?
Signup and view all the flashcards
How do you convert a string to lowercase in JavaScript?
How do you convert a string to lowercase in JavaScript?
Signup and view all the flashcards
What does the trim()
method do in JavaScript?
What does the trim()
method do in JavaScript?
Signup and view all the flashcards
What does the split()
method do in JavaScript?
What does the split()
method do in JavaScript?
Signup and view all the flashcards
Study Notes
JavaScript - Introduction - II
- Constant Variables: Constants cannot be re-declared or reassigned. They have block scope.
- Functions in JavaScript: A function is a block of code used for a particular task. It is executed when called or invoked. Functions can accept parameters.
- JavaScript Objects: A JavaScript object is a versatile collection of key-value pairs (properties) and actions (methods). You use objects to group related data and behaviors. Objects are variables that have properties and functions.
- Retrieving Object Properties: Accessing an object's property can be done in two ways: objectName["propertyName"] or objectName.propertyName
HTML Events
- HTML Events: Events can be actions resulting from a user or happening within the browser, such as page loading, user clicks, mouse movements, form input changes, and button clicks. Specific JavaScript code is often associated with these events.
Strings in JavaScript
- String Definition: Strings in JavaScript can use single or double quotes.
- Quotes within Strings: Nested quotes are possible as long as the enclosing quotes differ in style.
- Escape Characters: Special characters like apostrophes or backslashes can be included, using "".
- String Properties and Methods: JavaScript strings have properties such as
.length
and methods for various operations like.slice()
,.substring()
,.substr()
,.replace()
,.concat()
,.toUpperCase()
,.toLowerCase()
,.trim()
,.trimStart()
,.trimEnd()
,.split()
String Functions
- slice(start, end): A string function that extracts a portion of the string. If the end parameter is omitted, the rest of the string is extracted. The extracted string does not include the character at the end position
- substring(start, end): Extracts a portion of a string from one index to another. It treats negative values as zero and does not include the final index
- substr(start, length): Extracts characters starting at
start
for a specificlength
.
Variable Substitutions
- Variable substitutions in strings use template literals (
\
${expression}``) to substitute variables directly - String concatenation can use the
concat()
method or a plus (+
) operator
Additional notes
- The example code for various JavaScript string functions has been omitted but is readily accessible via the example links given.
- The presentation contained various examples of these JavaScript concepts.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz explores advanced concepts in JavaScript, including constant variables, functions, and objects. You'll learn how to retrieve object properties and understand HTML events alongside string handling in JavaScript. Dive deeper into the fundamentals of programming with this engaging assessment.