Update JavaScript style (Chapter of Array and Linkedlist)
This commit is contained in:
		| @@ -14,8 +14,8 @@ function randomAccess(nums) { | |||||||
| } | } | ||||||
|  |  | ||||||
| /* 扩展数组长度 */ | /* 扩展数组长度 */ | ||||||
| // 请注意,Python 的 list 是动态数组,可以直接扩展 | // 请注意,JavaScript 的 Array 是动态数组,可以直接扩展 | ||||||
| // 为了方便学习,本函数将 list 看作是长度不可变的数组 | // 为了方便学习,本函数将 Array 看作是长度不可变的数组 | ||||||
| function extend(nums, enlarge) { | function extend(nums, enlarge) { | ||||||
|     // 初始化一个扩展长度后的数组 |     // 初始化一个扩展长度后的数组 | ||||||
|     const res = new Array(nums.length + enlarge).fill(0); |     const res = new Array(nums.length + enlarge).fill(0); | ||||||
|   | |||||||
| @@ -48,12 +48,6 @@ for (const n of list) { | |||||||
|     count++; |     count++; | ||||||
| } | } | ||||||
|  |  | ||||||
| /* 直接遍历列表元素 */ |  | ||||||
| count = 0; |  | ||||||
| for (const n of list) { |  | ||||||
|     count++; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /* 拼接两个列表 */ | /* 拼接两个列表 */ | ||||||
| const list1 = [6, 8, 7, 10, 9]; | const list1 = [6, 8, 7, 10, 9]; | ||||||
| list.push(...list1); | list.push(...list1); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user