'convert module.export to es6
I am trying to convert this function to es6 sintax:
module.exports = function( key, fieldID ) {
var self = this;
self.Elements = function() {
this.cache = {
$btn: jQuery( '#dav' + key + '_button' ),
$apiField: jQuery( '#dav' + key ),
$apiUrl: jQuery( '#dav' + fieldID ),
};
};
};
Should start like this:
export default ( key, fieldID ) => {
const self = this;
self.Elements = function() {...
What is the correct way to convert this module to es6?
Solution 1:[1]
I think the following should work:
export default function(key, fieldID) {
var self = this;
self.Elements = function() {
this.cache = {
$btn: jQuery('#dav' + key + '_button'),
$apiField: jQuery('#dav' + key),
$apiUrl: jQuery('#dav' + fieldID),
};
};
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Apollo79 |
