Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28551

Re: function in hash

From Andreas Bergmaier <andber93@web.de>
Newsgroups comp.lang.javascript
Subject Re: function in hash
Date 2015-08-21 11:39 +0200
Organization albasani.net
Message-ID <mr6rjc$dbi$1@news.albasani.net> (permalink)
References <259c4391-a79d-43c9-b4f4-d6b3896ab9e3@googlegroups.com> <b458a4bb-90fb-43ef-96fb-2806bec85a23@googlegroups.com>

Show all headers | View raw


Stone Zhong schrieb:

>> I wrote some code below (Format A) by mistake:
>>
>> var a = {
>>    x: 1,
>>    y: 2,
>>    foo() {
>>      alert("foo");
>>    },
>> };
>>
>> to my surprise, this works well in Firefox 38.2.0, I haven't tried other browser, am I missing anything?
>
> Another ES5 black magic?

Nope, ES6 magic. It's called a method definition: 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions

  Bergi

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

function in hash Stone Zhong <stone.zhong@gmail.com> - 2015-08-20 23:20 -0700
  Re: function in hash Stone Zhong <stone.zhong@gmail.com> - 2015-08-20 23:21 -0700
    Re: function in hash Andreas Bergmaier <andber93@web.de> - 2015-08-21 11:39 +0200
      Re: function in hash Stone Zhong <stone.zhong@gmail.com> - 2015-08-21 07:41 -0700

csiph-web