0👍
✅
You can use ES6 shorter syntax for method definitions on objects initializers.
Chart.controllers.line = Chart.controllers.line.extend({
draw () {
const ctx = this.chart.chart.ctx;
If you use lower version of js, you can:
Chart.controllers.line = Chart.controllers.line.extend({
draw: function draw () {
const ctx = this.chart.chart.ctx;
You can check how ES6 syntax is converted to older js with babel: interactive example
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions
0👍
I don’t think you do need to convert it to an arrow function. Try this style of object literal method declaration:
Chart.controllers.line = Chart.controllers.line.extend({
draw() {
//...
}
})
Source:stackexchange.com