Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active November 8, 2023 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trikitrok/87c83eb8ceb520a0edcfeebd20949e78 to your computer and use it in GitHub Desktop.
Save trikitrok/87c83eb8ceb520a0edcfeebd20949e78 to your computer and use it in GitHub Desktop.
// From Rachel M. Carmena's https://github.com/rachelcarmena/code-smells
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
class CoolStack extends Array {
push(...items) {
return super.push(...items);
}
public pop() {
return super.pop();
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
class CoolStack {
constructor() {
this.elements = [];
}
push(...items): number {
this.elements.push(...items);
return this.elements.length;
}
pop() {
const element = this.elements[this.elements.length-1];
this.elements.pop();
return element;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment