google / google/closure-compiler
variable could be assigned at declaration
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I believe the output from advanced mode could be (mildly) optimised from `var a;a=window.setTimeout;` to `var a=window.setTimeout;` without causing any issues.
The full input file was:
```
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// ==/ClosureCompiler==
function hello(name) {
alert('Hello, ' + name);
}
var timer;
if( true ){ // or a truthy variable
timer = window['setTimeout'];
}
timer(function(){ hello('New user'); },100);
timer(function(){ hello('something else'); },100);
```
producing
```
var a;a=window.setTimeout;a(function(){alert("Hello, New user")},100);a(function(){alert("Hello, something else")},100);
```
Contributor guide
Assessment
This issue has not been assessed yet.