Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (2) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2015-06-26 (1 year ago) | Not yet rated by the users | Total: 45 | All time: 456 This week: 36 |
Version | License | JavaScript version | Categories | |||
es5spread 1.0 | Freely Distributable | 1.0 | Data types, Language |
The latest version of JavaScript allows you to pass variables, arrays and iterators into a function using code such as: var a = 1; var b = [2,3]; var c = [4,5,6].values(); fn(a, ...b, ...c); The ES2015 spread operator (eg ...c) is not recognised in older versions of JavaScript. While we can't get old versions of JavaScript to recognise this new syntax, we can implement a similar syntax to achieve the same end result. By implementing this spread method we can make a milor change to the above code and have it run in any version of JavaScript. var a = 1; var b = [2,3]; var c = [4,5,6].values(); fn.__(a, b, c) Bonus ----- Generate iterators from arrays with these polyfills (not found in any of the usual places you'd look for polyfills) Array.entries( ) - returns an array Iterator object containing key/value pairs for each entry in the array. Array.keys() - returns an array Iterator object containing the key for each entry in the array. Array.values() - returns an array Iterator object containing the value for each entry in the array. |
Files |
File | Role | Description |
---|---|---|
description | Doc. | How to use the ES5 spread operator |
spread.js | Class | A spread operator for ES5 |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.