News for hackers. Stuff that matters.
Re:15 years trying to make everyone separate HTML, JavaScrip... by Already__Taken on Tuesday December 20, 2016 @03:55AM (#13218414)
What is 'build = (): string => {' ?

Or specifically ():, I know arrow functions.

Re:15 years trying to make everyone separate HTML, JavaScrip... by igl on Tuesday December 20, 2016 @04:08AM (#13218450)
() = empty arguments. you can only omit the braces when you have 1 argument. 0 and 2+ require the braces. #tc39

the colon refers to flow and typescripts type annotation "colon something". none-objects are lowercased

Re:15 years trying to make everyone separate HTML, JavaScrip... by mcbits on Tuesday December 20, 2016 @08:08AM (#13219449)
It's similar to writing

    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.

Re:15 years trying to make everyone separate HTML, JavaScrip... by ClayFerguson on Tuesday December 20, 2016 @11:00AM (#13220958)
That strange syntax with the arrow function is only needed so that the 'this' inside the function behaves the way one would expect it to in normal OOP language. It 'captures' the this for the object itself (like C++ would, etc). But that 'build()' function is what constructs a string that is the content for the dialog.
Re:15 years trying to make everyone separate HTML, JavaScrip... by scottmf on Tuesday December 20, 2016 @05:47AM (#13218813)
Looks like build is the function and it returns a string.

I think without the typing it would just be build = () => {

Re:15 years trying to make everyone separate HTML, JavaScrip... by Already__Taken on Wednesday December 21, 2016 @03:41AM (#13227680)

    var build = function(){...} //return a string
Rather than some other commenters, and I would have thought given arrow functions;

    var build = function(string){...}
Re:15 years trying to make everyone separate HTML, JavaScrip... by scottmf on Wednesday December 21, 2016 @02:03PM (#13231688)
I don't understand what you're trying to say?