Skip to content

Instantly share code, notes, and snippets.

@rgbkrk
Last active March 12, 2016 20:54
Show Gist options
  • Save rgbkrk/fd05cbd1c7b8c3feb1f2 to your computer and use it in GitHub Desktop.
Save rgbkrk/fd05cbd1c7b8c3feb1f2 to your computer and use it in GitHub Desktop.
Tinkering with v8
function Console() {
}
Console.prototype.log = function() {
print(...arguments);
}
Console.prototype.error = function() {
print(...arguments);
}
const console = new Console();
console.log('hey', 'there');

If you install v8 and try it out on the command line, you'll notice a lack of console.log (same for d8). The only related function I found available was print, so I made a fake console.log. Since I'm on V8 version 4.8.271.17, the spread operator is available.

function log() {
  print(...arguments)
}

That's clearly missing nuance, though it was fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment