You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea boils down to not preserving the .length property of a function to enable:
removing unused arguments from function definition
putting variable declarations into the function definition
This would be a unsafe option.
Examples:
// input:functionhelloWorld(unused){console.log("Hello, World!")}helloWorld();helloWorld();// twice so it doesnt inline// output:functionhelloWorld(o){console.log("Hello, World!")}helloWorld(),helloWorld();// ^ unused variable// could be (saves 1 byte)functionhelloWorld(){console.log("Hello, World!")}helloWorld(),helloWorld();
// input:functionfoo(){vara=console.log.bind(console)a("Test 1")a("Test 2")}foo()foo()// output:functionfoo(){varo=console.log.bind(console);o("Test 1"),o("Test 2")}foo(),foo();// could be (saves 3 bytes)functionfoo(o){o=console.log.bind(console);o("Test 1"),o("Test 2")}foo(),foo();
Potentially the assignment could also be done via default values, however I am not quite sure how safe this is.
For example:
// could be (saves 2 additional bytes)functionfoo(o=console.log.bind(console)){o("Test 1"),o("Test 2")}foo(),foo();
Describe the feature
The idea boils down to not preserving the
.length
property of a function to enable:This would be a unsafe option.
Examples:
Potentially the assignment could also be done via default values, however I am not quite sure how safe this is.
For example:
Babel plugin or link to the feature description
No response
Additional context
Playground example
The text was updated successfully, but these errors were encountered: