Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EC5 Spead Operator Sample Unused Variable #94

Closed
WillCallahan opened this issue Jun 5, 2017 · 1 comment
Closed

EC5 Spead Operator Sample Unused Variable #94

WillCallahan opened this issue Jun 5, 2017 · 1 comment

Comments

@WillCallahan
Copy link

The following ECMAScript 5 sample has an unused variable.

var params = [ "hello", true, 7 ];
var other = [ 1, 2 ].concat(params); // [ 1, 2, "hello", true, 7 ]
f.apply(undefined, [ 1, 2 ].concat(params)) === 9;

var str = "foo";
var chars = str.split(""); // [ "f", "o", "o" ]

The previously mentioned code should be changed to the following.

var params = [ "hello", true, 7 ];
var other = [ 1, 2 ].concat(params); // [ 1, 2, "hello", true, 7 ]
f.apply(undefined, other) === 9;

var str = "foo";
var chars = str.split(""); // [ "f", "o", "o" ]
@rse
Copy link
Owner

rse commented Jun 5, 2017

Yes and no. Yes, one could use "other" here, of course. But that's no the point. The "var other ..." line is not there for the following line, but illustrates the spread operator just fine for itself in a stand-alone way. So, no, I will not reuse other as the "f.apply ...." line is a different usage of the spread operator and should be understood separately. Instead, I've now copied over the "f" definition from the Rest Operator example and added a blank line to make it more clear that the two Spread Operator examples are unrelated to each other.

@rse rse closed this as completed Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants