Skip to content

Instantly share code, notes, and snippets.

@guangtuan
Last active June 6, 2019 12:53
Show Gist options
  • Save guangtuan/9b03f504377f1b34329df37392dc615f to your computer and use it in GitHub Desktop.
Save guangtuan/9b03f504377f1b34329df37392dc615f to your computer and use it in GitHub Desktop.
recursive in JavaScript anonymous function
const head = {
val: 1,
next: {
val: 2,
next: {
val: 3
}
}
};
(function (head) {
console.log(head.val);
if (head.next) {
arguments.callee(head.next);
} else {
return;
}
})(head);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment