Last active
September 23, 2016 13:05
-
-
Save ethanmick/ad7cae12416cda676bcc895ba588cc5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'use strict'; | |
class Test { | |
constructor(opts = {}) { | |
// NOTE: No Semicolon at the end of this line | |
const example = JSON.parse(opts.example) | |
({ | |
id: this.id, | |
} = example) | |
} | |
} |
This file contains hidden or 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
'use strict'; | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var Test = function Test() { | |
var _example; | |
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | |
_classCallCheck(this, Test); | |
var example = JSON.parse(opts.example)((_example = example, this.id = _example.id, _example)); | |
}; |
This file contains hidden or 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
'use strict'; | |
class Test { | |
constructor(opts = {}) { | |
// NOTE: Semicolon at the end of this line | |
const example = JSON.parse(opts.example); | |
({ | |
id: this.id, | |
} = example) | |
} | |
} |
This file contains hidden or 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
'use strict'; | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var Test = function Test() { | |
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | |
_classCallCheck(this, Test); | |
var example = JSON.parse(opts.example); | |
this.id = example.id; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using ES6 destructuring to assign values to
this
, you need to be careful how the parenthesis are interpreted!