Created
February 16, 2013 01:34
-
-
Save OscarGodson/4965027 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set multiple vars / obj props to the same value | |
| el.style.width = x; | |
| newWidth = x; | |
| eventData.width = x; | |
| // Set x as the value to these vars / obj props | |
| x => (el.style.width, newWidth, eventData.width); |
LOL @techwraith
I thought JavaScript had a kind of multiple-assignment on the left-hand side, but maybe I was thinking of Ruby:
a, b, c = [1,2,3]
CoffeeScript has that destructuring assignment, in the form of:
[a, b, c] = [1,2,3]
I guess I was thinking, (with the addition of a repeat utility method), you could something like
el.style.width, newWidth, eventData.width = repeat(x, 3)
Where repeat just makes an array by repeating x n times.
What @techwraith said
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You mean like this?