es6-interactive-guide icon indicating copy to clipboard operation
es6-interactive-guide copied to clipboard

Concise methods example

Open mxstbr opened this issue 9 years ago • 0 comments

In the concise methods section the explanation provided is:

"In object literals and classes we can condense render: function () {} to render()"

And the example is the following:

const foo = function () {
  return "foo"
};

const a = "a";

const obj = {foo, a};

console.log(obj.foo());
console.log(obj.a);

This doesn't showcase at all what the description says. I think a better example would be something like:

const obj = {
  foo() {
    return "a";
  }
};

console.log(obj.foo());

With the console output:

"a"

Would be happy to submit a PR if you think that aligns with the goals of this project! Great resource by the way!

mxstbr avatar Jan 25 '16 15:01 mxstbr