Fomrat the JS and TS codes with prettier.

This commit is contained in:
krahets
2023-04-17 21:58:11 +08:00
parent 9a98ff8a5e
commit c4ea4e39f3
68 changed files with 634 additions and 510 deletions

View File

@ -6,7 +6,7 @@
/* Driver Code */
/* 初始化栈 */
// Javascript 没有内置的栈类,可以把 Array 当作栈来使用
// Javascript 没有内置的栈类,可以把 Array 当作栈来使用
const stack = [];
/* 元素入栈 */
@ -15,21 +15,21 @@ stack.push(3);
stack.push(2);
stack.push(5);
stack.push(4);
console.log("栈 stack =", stack);
console.log('栈 stack =', stack);
/* 访问栈顶元素 */
const peek = stack[stack.length - 1];
console.log("栈顶元素 peek =", peek);
console.log('栈顶元素 peek =', peek);
/* 元素出栈 */
const pop = stack.pop();
console.log("出栈元素 pop =", pop);
console.log("出栈后 stack =", stack);
console.log('出栈元素 pop =', pop);
console.log('出栈后 stack =', stack);
/* 获取栈的长度 */
const size = stack.length;
console.log("栈的长度 size =", size);
console.log('栈的长度 size =', size);
/* 判断是否为空 */
const isEmpty = stack.length === 0;
console.log("栈是否为空 =", isEmpty);
console.log('栈是否为空 =', isEmpty);