Chap. 4 eloquent javascript Flashcards
let listOfNumbers = [2, 3, 5, 7, 11];
console.log(listOfNumbers[2]);
console. log(listOfNumbers[0]);
console. log(listOfNumbers[2 - 1]);
// → 5 // → 2 // → 3
Almost all JavaScript values have properties. The exceptions are______ and________.
null
undefined
true or false?
null has properties
false
The two main ways to access properties in JavaScript are with a _________ and with ____________.
dot notation
square brackets
null.length;
returns?
// → TypeError: null has no properties
Write in bracket notation
array.length
array[‘length’]
Write in dot notation
array[‘length’]
array.length
let doh = "Doh"; console.log(typeof doh.toUpperCase);
// → function
let doh = "Doh"; console.log(doh.toUpperCase());
// → DOH
let sequence = [1, 2, 3];
sequence. push(4);
sequence. push(5);
console. log(sequence);
// → [1, 2, 3, 4, 5]
let sequence = [1, 2, 3, 4, 5];
console.log(sequence.pop());
console.log(sequence);
// →5
// → [1, 2, 3, 4]
let day1 = { squirrel: false, events: ["work", "touched tree", "pizza", "running"] };
console. log(day1.squirrel);
console. log(day1.wolf);
day1. wolf = false;
console. log(day1.wolf);
// → false // → undefined // → false
Properties in objects whose names aren’t valid binding names or valid numbers have to be_________.
quoted
let anObject = {left: 1, right: 2}; console.log(anObject.left); // → delete anObject.left;
console.log(“left” in anObject);
// →
console.log(“right” in anObject);
// →
// → 1
// → false // → true
To find out what properties an object has, you can use the ___________ function
Object.keys