Index

January 8, 2018

《忍者秘籍》第二版笔记 第九章

Array

客观的说,这本书对于Array的讲述比较照本宣科。有一些关键的内容没有涉及:

Map

Set

练习

9.5.1

["Oda", "Tomoe", undefined, "Hattori"]

9.5.2

["Hattori", "Yoshi"]

9.5.3

["Tomoe", "Hattori", "Takeda"]

这里书的答案里的result是对的,但是解释错了,官方勘误是:

The value of samurai is ["Tomoe", "Hattori", "Takeda"]. The array starts empty; push adds Oda to the end, and unshift adds Tomoe to the beginning; splice here does not remove any items, but inserts Hattori and Takeda starting at index 1 (after Tomoe), and the final pop method removes Oda from the end of the Array.

9.5.4


// first
[18, 19, 20]

// second
[18, 20]

// third
57

9.5.5


// first
true

// second
false

9.5.6

The second one.

9.5.7

The third one.

书里答案错了,官方勘误是:

The next to last assertion will pass because Toyotomi is part of our set. The last assertion will fail because we never attempted to make Hattori a part of our set.