Had an interview. So I had interesting question about "what would console log output".(There might be a lot of people wondering the same stuff, I tried to read docs but no way, couldn't get)
It's a bit confusing, so I don't understand why link() outputs undefined and hero.getKek() => test. Odd behaviour isn't it ? link===hero.getKek. So these are the same functions, I would say, using "this" make function less controllable. Why Can't I create an alias for long chained nested object field, I HAVE to repeat the same chaining ? a.b.c.d.e.g() = > "test", alias() => "test" makes more sense. I can use call or apply to borrow context for link function, but that still doesn't have any logic for me
const hero={
kek:'test',
getKek:function (){
console.log(this.test);
}
}
const link=hero.getKek;
link(); // undefined (why?)
hero.getKek() // test