These are chat archives for airbnb/javascript

16th
Nov 2016
Nick George
@Izzmo
Nov 16 2016 00:09
always
jklesmes17
@jklesmes17
Nov 16 2016 06:10
hi guys good day..
it is okey to return an empty array ? is it a good way practice ?
var path = (path.length > 0) ? path.filter( (data) -> data != "" ) : [];
Jordan Harband
@ljharb
Nov 16 2016 06:36
it's totally fine
altho -> isn't javascript
jklesmes17
@jklesmes17
Nov 16 2016 06:40

@ljharb ahh okey thanks..

(data) -> it is ES6 arrow function :)

@ljharb .. i thought it is a bad returning value. Thanks again :)
Jordan Harband
@ljharb
Nov 16 2016 06:41
an ES6 arrow function is =>
no, it's not
-> is either coffeescript or nothing
jklesmes17
@jklesmes17
Nov 16 2016 06:42
ahh yeah.. sorry for for that. typo error :'(
Jordan Harband
@ljharb
Nov 16 2016 06:42
but also, there's no need for the ternary there.
if path.length is 0, then path.filter(anything) will return the empty array anyways
so you can just return path.filter(data => data !== '')
or whichever
(also, always use !== over !=)
jklesmes17
@jklesmes17
Nov 16 2016 06:43
ahhh. i see thanks for that. i learn something from you :) !== is a good to use
Jordan Harband
@ljharb
Nov 16 2016 06:51
also === over ==