What is 'build = (): string => {' ?
Or specifically ():, I know arrow functions.
Or specifically ():, I know arrow functions.
the colon refers to flow and typescripts type annotation "colon something". none-objects are lowercased
build(): string { ...
but they generate different JavaScript. The way it's written will give each instance its own reference to the function. The "build(): string" above will add the function to the prototype, which is shared by all instances.I'm not sure whether the code takes advantage of this difference in some way or not. If not, it's just a slightly more awkward and less efficient way of defining a method.
I think without the typing it would just be build = () => {
var build = function(){...} //return a string
Rather than some other commenters, and I would have thought given arrow functions; var build = function(string){...}