Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upSpread operator within ternary operator #478
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Feature proposal discussions belong on es-discuss. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
var x = [1,2];
var y = [];
y.concat(x); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
topaxi
Mar 16, 2016
See leobalters version, if your usecase needs push you can use:
var x = [1,2];
var y = [];
y.push(...Array.isArray(x) ? x : [ x ]);
topaxi
commented
Mar 16, 2016
|
See leobalters version, if your usecase needs var x = [1,2];
var y = [];
y.push(...Array.isArray(x) ? x : [ x ]); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
lewispham
commented
Mar 16, 2016
|
@leobalter Very nice suggestion if I don't mind creating a new array. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
lewispham
Mar 16, 2016
@topaxi It looks like a workaround rather than an official method for the case. Also, I personally think it's a bit less readable.
lewispham
commented
Mar 16, 2016
|
@topaxi It looks like a workaround rather than an official method for the case. Also, I personally think it's a bit less readable. |
bterlson
closed this
Mar 17, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
Not the appropriate venue for this discussion. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lewispham commentedMar 16, 2016
I think it would be nice to be able to use spread operator like this: