diff --git a/codes/javascript/chapter_stack_and_queue/stack.js b/codes/javascript/chapter_stack_and_queue/stack.js index 1b2e83b..9afbdc2 100644 --- a/codes/javascript/chapter_stack_and_queue/stack.js +++ b/codes/javascript/chapter_stack_and_queue/stack.js @@ -16,13 +16,13 @@ stack.push(5); stack.push(4); /* 访问栈顶元素 */ -peek = stack[stack.length - 1]; +const peek = stack[stack.length - 1]; /* 元素出栈 */ -pop = stack.pop(); +const pop = stack.pop(); /* 获取栈的长度 */ -size = stack.length; +const size = stack.length; /* 判断是否为空 */ -is_empty = stack.length === 0; +const is_empty = stack.length === 0; diff --git a/docs/chapter_stack_and_queue/stack.md b/docs/chapter_stack_and_queue/stack.md index d738598..eed7033 100644 --- a/docs/chapter_stack_and_queue/stack.md +++ b/docs/chapter_stack_and_queue/stack.md @@ -155,16 +155,16 @@ comments: true stack.push(4); /* 访问栈顶元素 */ - peek = stack[stack.length-1]; + const peek = stack[stack.length-1]; /* 元素出栈 */ - pop = stack.pop(); + const pop = stack.pop(); /* 获取栈的长度 */ - size = stack.length; + const size = stack.length; /* 判断是否为空 */ - is_empty = stack.length === 0; + const is_empty = stack.length === 0; ``` === "TypeScript"