bendc / frontend-guidelines

Some HTML, CSS and JS best practices.
8.29k stars 653 forks source link

Lamda syntax might cause confusion #9

Closed AndyScott77 closed 9 years ago

AndyScott77 commented 9 years ago

I think many devs would understand the Lamda syntax you're using for your JavaScript examples; such as :

// bad
const toArray = obj => [].slice.call(obj);

// good
const toArray = (() =>
  Array.from ? Array.from : obj => [].slice.call(obj)
)();

But ...

"This is an experimental technology, part of the ECMAScript 6" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Browser_compatibility

And I believe only the Gecko (Firefox) engine support them; I know the current Chrome I use (40.0.2214.115) doesn't support this Lamda syntax - I do wish they all would tho!

Regardless, it might be a source of confusion for readers - especially ones that might try to understand the example by running it.

bendc commented 9 years ago

It's just part of the ES2015 specification -- all browsers will support this syntax eventually.

AndyScott77 commented 9 years ago

While that maybe the case, you should make this clear that the example will only run in Gecko. I'm assuming the audience you're targeting aren't people that know the full 'ins & outs' of the different rendering engines?

pierrocknroll commented 9 years ago

I totally agree with NET4ORCE. Your exemples are not clear enough and not documented/sourced. Some of them are just "your opinion" and absolutly not good practices.

Overestimated !

AndyScott77 commented 9 years ago

@bendc While much of your guide does indeed cover best practices, and please understand I admire you & your efforts for writing the guidelines, you must have noted that more and more of the issues raised by others have cited "preference" or "opinion". Do you not think it's worth indicating such through the guide?

Please note, and appreciate the guide been linked out via a number of large content aggregators; there will be a significant number of developers that won't consider the points raised by others.