Message from JavaScript discussions

September 2020

β€” 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:

persons.map(person => person.getAge())


in FP Style:
persons.map(getAge)

β€” ScatteredπŸ˜‘

β€” Expressive, I would say 🧐

β€” Could it be that the code generates a situation, where age is the same for each person? so where ever I change age it will be the identical value, while

myFather.name= "John"; myMother.name="Jane";

stay disjunct properties?

Message permanent page

β€” Unlikely

β€” So why the heck was it implemented like that?

β€” What exactly?

β€” This line:
this.hasAge = this.hasAge.bind(this);

β€” Because its a schoolar example for learning, probably

β€” I'll send you a link to the original code
its not scholar sample.

β€” Does onload work for other things than window? I tried this but it doesn't seem to work:

var myJS = document.createElement('script');
myJS.type = 'text/javascript';
myJS.src = '/path/to/my.js';
document.querySelector('head').appendChild(myJS);
myJS.onload = someFunction();

Message permanent page