Message from JavaScript discussions

September 2020

— Now say how "bad" is this🤤 decided to re-name a bit


"callback" might be the keyword.
the code I am looking into is part of a large project, and there are "callback functions".
in fact gapi is used to access G-drive.

the tips on how to change are generally welcome, but first i need to understand what this part of the code is doing and why certain syntax was used.

we have already seen, that dropping the "bind" line has an effect (native code).

so what is this on "callback" you mentioned. can you elaborate?

— (native code) means (don't put your nose) or😅 i can't see what you see, binding means additional (native) code will be generated, right.. operations aren't free😫

Message permanent page

— Callback is mouse.onclick = callback where callback = handler.bind(scope) is bound, might be => in the constructor function..

function Person(age) {
this.age = age;
this.hasAge = () => this.age
//this.hasAge = () => age

Message permanent page

— I think better would be getAge instead of hasAge.. otherwise I would expect boolean value

— Exactly

— Or if you like functional style:

const person = age => ({ age })
const getAge = person => person.age
const father = person(50)
const fatherAge = getAge(father)

Message permanent page

— Const const const const 🤤

— Yes.. a good brick wall is better than a v-shaped mess

— If you have now an array of persons.. how do you retrieve their age?
in OOP style: => person.getAge())

in FP Style:

Message permanent page

— Scattered😑

— Expressive, I would say 🧐