Created
May 12, 2016 19:52
-
-
Save KKrisu/9fc27b1c709e34a2d52f287cf473aaea to your computer and use it in GitHub Desktop.
Object literal ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parent.console.clear(); | |
// var {a, b} = {a: 1, b: 2}; | |
var a = 1; | |
var b = 2; | |
// console.log(a, b); | |
var bar = 'test'; | |
var o = { | |
// a: a, | |
// b: b, | |
a, b, | |
['b' + 2]: 4, | |
[bar]: 8, | |
f1: function() {}, | |
f2() {}, | |
// get foo() {...}, | |
// set foo(value) {...}, | |
}; | |
o['a' + 1] = 3; | |
Object.defineProperty(o, 'foo', { | |
get: () => { | |
return 3; | |
}, | |
set: (value) => { | |
console.log('set to', value); | |
} | |
}); | |
console.log(o.foo); | |
o.foo = 5; | |
console.log(o); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment