super.method()
function
, пусть и после .bind()
First the memory and performance; When you use a class field to define a function, your whole method resides on each instance of the class and NOT on the prototype, but using the bind technic, just a small callback is stored on each instance, which calls your method that is stored on the prototype.
Second thing that can be affected is how you write your unit tests. You won't be able to use the component prototype to stub on function calls like below:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
// пример других алиасов (копия webpack aliases):
"src/*": [
"src/*"
],
"scripts/*": [
"scripts/*"
],
"app/*": [
"*"
],
"components/*": [
"src/components/*"
],
"layouts/*": [
"src/layouts/*"
],
"pages/*": [
"src/pages/*"
],
"assets/*": [
"src/assets/*"
],
"boot/*": [
"src/boot/*"
]
}
},
"exclude": [
"dist",
"node_modules",
//... другие не нужные пути
]
}
<div class="wrap_input">
<input name="worker" class="input_text" type="text" spellcheck="false" value="">
<span>Работник:</span>
</div>
.wrap_input{
display: flex;
flex-flow: column-reverse;
}
const foo = function foo(dateOrig) {
const date = new Date(dateOrig)
// код, который мутирует date и что-нибудь возвращает
}
function getDayOfWeek1stDayOfMonth(date) {
const firstDayOfMonth = new Date(date)
firstDayOfMonth.setDate(1)
return firstDayOfMonth.getDay();
}
const dayOfWeek = dayjs(date).startOf('month').get('day')
// bad
$('#items').find('.selected').highlight().end().find('.open').updateCount();
// bad
$('#items').
find('.selected').
highlight().
end().
find('.open').
updateCount();
// good
$('#items')
.find('.selected')
.highlight()
.end()
.find('.open')
.updateCount();
// bad
const leds = stage.selectAll('.led').data(data).enter().append('svg:svg').classed('led', true)
.attr('width', (radius + margin) * 2).append('svg:g')
.attr('transform', `translate(${radius + margin},${radius + margin})`)
.call(tron.led);
// good
const leds = stage.selectAll('.led')
.data(data)
.enter().append('svg:svg')
.classed('led', true)
.attr('width', (radius + margin) * 2)
.append('svg:g')
.attr('transform', `translate(${radius + margin},${radius + margin})`)
.call(tron.led);
// good
const leds = stage.selectAll('.led').data(data);