question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checking arguments.length slow

See original GitHub issue

Checking arguments.length slow with Chakra. Here is sample page:

<html>
<body>
<script>
var start = Date.now();

function one(a){
}

function two(a,b){
}

function route(a,b){
   switch (arguments.length) {
   case 1:
     return one(a);
   case 2:
     return two(a,b);
   }
}

for (var i = 0; i<1000000; i++) {
  route(1,2);
}

document.write(Date.now() - start);
</script>
</body>
</html>

My results:

  • Edge: ~380ms
  • Chrome: ~20ms
  • Firefox: ~3ms

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
satheeshravicommented, Jun 3, 2016

This issue will be fixed in https://github.com/Microsoft/ChakraCore/pull/1023. This is a WIP item. strict and non-strict mode should be taken care with this change.

0reactions
satheeshravicommented, Sep 8, 2016

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How best to determine if an argument is not sent to the ...
Checking arguments.length exhibits the 'most correct' behaviour, but it might not be feasible if there's more than one optional argument. The ...
Read more >
arguments.length - JavaScript - MDN Web Docs
The arguments.length property provides the number of arguments actually passed to a function. This can be more or less than the defined ...
Read more >
ARG_MAX, maximum length of arguments for a new process
In a loop with increasing n, the check tries an exec() with an argument length of 2 n (but won't check for n...
Read more >
Faster JavaScript calls
We check that we have a mismatch between argument size and parameter count and jump to ArgumentsAdaptorTrampoline . In this built-in, we build ......
Read more >
Checking Arguments in R Functions
With ArgumentCheck , we'll create an object that, based on the results of a logical test, will store any error and warning messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found