Skip to content

Instantly share code, notes, and snippets.

@caitp
Created December 22, 2014 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caitp/189ad92b55c9f871d55b to your computer and use it in GitHub Desktop.
Save caitp/189ad92b55c9f871d55b to your computer and use it in GitHub Desktop.
It's kinda broken, but at least it's creating arrays of the right sizes and not crashing <_<
STRICT MODE
[]
[3,32767]
[2]
SLOPPY 'FAST' MODE
[]
[3,32767]
[2]
SLOPPY 'SLOW' MODE
[2]
[4,32767,null]
[3,32767]
(function() {
"use strict";
function fn(a, ...b) {
return b;
}
print("STRICT MODE");
print(JSON.stringify(fn(1)));
print(JSON.stringify(fn(1, 2, 3)));
print(JSON.stringify(fn(1, 2)));
print("\n");
})();
(function() {
function fn(a, ...b) {
return b;
}
print("SLOPPY 'FAST' MODE");
print(JSON.stringify(fn(1)));
print(JSON.stringify(fn(1, 2, 3)));
print(JSON.stringify(fn(1, 2)));
print("\n");
})();
(function() {
function fn(a, a, ...b) {
return b;
}
print("SLOPPY 'SLOW' MODE");
print(JSON.stringify(fn(1, 1)));
print(JSON.stringify(fn(1, 1, 2, 3)));
print(JSON.stringify(fn(1, 1, 2)));
print("\n");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment