argumentsLimits.js 844 B

12345678910111213141516171819202122
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. let limit = (1 << 16) - 4;
  6. function test0() {
  7. return arguments[limit - 1];
  8. }
  9. while (true) {
  10. try {
  11. const txt = `test0(${Array(limit).fill(0).map((_, i) => i).join(",")})`;
  12. var val1 = eval(txt);
  13. console.log(`arguments[${limit - 1}] == ${val1}`);
  14. break;
  15. } catch (e) {
  16. console.log(e)
  17. console.log(`${limit} is too many arguments`);
  18. limit--;
  19. }
  20. }
  21. console.log(`Arguments limit: ${limit}`);