Skip to content

Instantly share code, notes, and snippets.

@ckymn

ckymn/shift.js Secret

Created March 6, 2021 07:34
Show Gist options
  • Save ckymn/8748ae4d56de4cb6233dc2600f8776ed to your computer and use it in GitHub Desktop.
Save ckymn/8748ae4d56de4cb6233dc2600f8776ed to your computer and use it in GitHub Desktop.
shift() {
if (!this.head) return null;
let currentHead = this.head;
this.head = this.currentHead.next;
this.length--;
if(this.length === 0){
this.tail = null;
}
return currentHead;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment