An odd json usage

javascript, json

Solution

As far as I know the keyword `get` just classifies `x()` as a getter, and appears to self-invoke. It's not supported in jScript (IE) and it's not a reserved word.

You'd reference it like so: `obj.x; // 17`

In lamen's terms, these will behave identically:

var foo = { get x() { return 17; } };  
document.write(foo.x);​ // 17

var bar = { x: function() { return 17; } };  
document.write(bar.x());​ // 17

Problem

I saw a part of javascript code on MDN and I am wondering how to work below code and what does it mean ? ``` var obj = { get x() { return 17; } }; ```

Original source