Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Private class fields

node v16.18.0
version: master
endpointsharetweet
// Supported since node 12 // Produces SYNTAX ERROR: Unexpected character '#' // This is bull. Please fix. // https://thecodebarbarian.com/nodejs-12-private-class-fields.html // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields const code_that_SHOULD_run_directly = ` class Foo { #b = 15; get() { return this.#b; } increment() { ++this.#b; } } const foo = new Foo() console.log(foo.get()) console.log(foo.increment()) console.log(foo.get()) ` void (new Function(code_that_SHOULD_run_directly))()
Loading…

no comments

    sign in to comment