Foundation Flashcards
What does the console show: function foo() { return “bar”; } console.log( foo() );
bar
How do you access the beta property value in this code? let foo = { alpha: 1, beta: 2 };
foo.beta
What is the value of result?
let places = [{ city: ‘Amsterdam’, europe: true }, { city: ‘Paris’, europe: true }, { city: ‘Sacramento’, europe: false }];
let result = places[2].city;
Sacramento
Which DOM function returns an element based on its id attribute?
document.getElementById( id );
How many times will this loop execute?
let count = 5;
while (count) { console.log(count); count–; }
5
What shows in the console?
var message = “no”;
function foo(message) {
message = “yes”;
}
foo( message );
console.log( message );
no
T/F: A String is a iterable object
True. A String can be thought of as an array of characters
What is the output of the following:
function stringToArray(){
let productNumber = “ABC-123”
let values = [… productNumber]
return values; }
[“A”,” B”, “C”, “-“, “1”,” 2”, “3”]
What happens when you use spread operator to copy an object?
The new array is created, but the underlying objects are still the objects being referenced. So any operation performed on the copied array actually changes the referenced object.
What are primitive types in JavaScript?
- Data that is NOT an object and has no methods
- Boolean
- Undefined
- Number
- BigInt
- String
- Symbol
- Null