2👍
✅
Use toggle(elementId = 0, type = 'item') {}
instead of toggle: (elementId = 0, type = 'item') => {}
.
arrow function assigns this
to its parent’s this
of the scope.
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Arrow_functions_used_as_methods
Source:stackexchange.com