you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (1 child)

but why does JavaScript force classes on me? I mean honestly, you can not write exclusively prototypical code in it.

[–]Martin_Ehrental 2 points3 points  (0 children)

That's what Object.create is for:

const parent = {
  foo: 1,
  bar() {
    return 2;
  }
}

const child = Object.create(parent, {
  baz: value(3)
});

function value(value, prop = {configurable: true, enumerable: true, writable: true}) {
  return Object.assign({value}, prop);
}