Update JavaScript style (Chapter of Array and Linkedlist)

pull/95/head
justin 2022-12-12 21:33:30 +08:00
parent aceed8f87f
commit 3f39a8c3cc
2 changed files with 2 additions and 8 deletions

View File

@ -14,8 +14,8 @@ function randomAccess(nums) {
}
/* 扩展数组长度 */
// 请注意,Python 的 list 是动态数组,可以直接扩展
// 为了方便学习,本函数将 list 看作是长度不可变的数组
// 请注意,JavaScript 的 Array 是动态数组,可以直接扩展
// 为了方便学习,本函数将 Array 看作是长度不可变的数组
function extend(nums, enlarge) {
// 初始化一个扩展长度后的数组
const res = new Array(nums.length + enlarge).fill(0);

View File

@ -48,12 +48,6 @@ for (const n of list) {
count++;
}
/* 直接遍历列表元素 */
count = 0;
for (const n of list) {
count++;
}
/* 拼接两个列表 */
const list1 = [6, 8, 7, 10, 9];
list.push(...list1);