[英]Trying to use puppeteer plugin but I keep getting an error for Unhandled Promise Rejection: ReferenceError: Can't find variable: require
[英]I m trying to create a queue from stacks but I get the error “Can't find the variable require”
我是编程新手,我有一个练习来为堆栈创建一个队列,但是当我验证它时给我一个错误:
"队列是一个 class
TypeError: undefined is not an object(评估“Queue.prototype”)
const Stack = require('./stack');
class Queue {
constructor(){
this.first = new Stack();
this.second = new Stack();
}
add(record) {
this.first.push(record);
}
remove() {
while (this.first.peek()) {
this.second.push(this.first.pop());
}
const record = this.second.pop();
while (this.second.peek()) {
this.first.push(this.second.pop());
}
return(record);
}
peek() {
while (this.first.peek()) {
this.second.push(this.first.pop());
}
const record = this.second.peek();
while (this.second.peek()) {
this.first.push(this.second.pop());
}
return record;
}
}
module.exports = Queue;
一个简单的例子
class Animal{
species;
constructor(){}
}
class Dog extends Animal{
name;
constructor(){
super();
}
}
let max = new Dog();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.