alicancubukcuoglu at gmail.com (2016-01-22T22:34:28.009Z)
More cool stuff:
```javascript
const arr = [1, 2, 3];
// Easy push
arr[] = 4; // => arr[arr.length];
// Easy s(p)lice
arr[begin, end];,
arr[begin,]; // => arr[begin, arr.length - 1];
arr[begin, end] = [1, 2, 3];
```
A terrible example (terrible because this should be done with WebGL
shaders):
```javascript
const image = [ /* Umbagajillion of RGBA pixels */ ];
function manipulate(rgba) {
rgba[0] += 10;
rgba[1] += 10;
rgba[2] += 10;
}
for (let i = 0; i < image.length / 4; i++) {
const begin = i * 4;
const end = begin + 4;
/*
In case easy s(p)lice doesn't actually Array.p.slice
and just creates a limited view of the array
without breaking reference
(image[begin, end] === image[begin, end])
*/
manipulate(image[begin, end]);
/*
In case easy s(p)lice does Array.p.slice
and creates a new array
(image[begin, end] !== image[begin, end])
*/
const pixel = image[begin, end];
manipulate(pixel);
image[begin, end] = pixel;
}
```
Edit: Fixed the typo @kdex pointed out. Thanks!
More cool stuff: ```javascript const arr = [1, 2, 3]; // Easy push arr[] = 4; // => arr[arr.length]; // Easy s(p)lice arr[begin, end];, arr[begin,]; // => arr[begin, arr.length]; arr[begin, end] = [1, 2, 3]; ``` A terrible example (terrible because this should be done with WebGL shaders): ```javascript const image = [ /* Umbagajillion of RGBA pixels */ ]; function manipulate(rgba) { rgba[0] += 10; rgba[1] += 10; rgba[2] += 10; } for (let i = 0; i < image.length / 4; i++) { const begin = i * 4; const end = begin + 4; /* In case easy s(p)lice doesn't actually Array.p.slice and just creates a limited view of the array without breaking reference (image[begin, end] === image[begin, end]) */ manipulate(image[begin, end]); /* In case easy s(p)lice does Array.p.slice and creates a new array (image[begin, end] !== image[begin, end]) */ const pixel = image[begin, end]; manipulate(pixel); image[begin, end] = pixel; } ``` -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160122/4d2904b0/attachment.html>