r/learnjavascript • • Jul 20 '21

JavaScript Facts: Object And Array

252 Upvotes

23 comments sorted by

View all comments

6

u/senocular Jul 20 '21

Typo for "04.":

let anObj = {left:3, right: 2};
console.log(anObj.left); // -> 1

The initial literal should use left: 1 or the log should output // -> 3

The use of // -> for "05." can be a little confusing too since unshift() returns the length of the array and shift returns the number shifted off the array. Neither return the modified array as the use // -> suggests

1

u/hsnice Jul 20 '21

Thanks, senocular