Function hoisting

Neil Mix nmix at
Sat Jul 19 07:20:27 PDT 2008

On Jul 19, 2008, at 12:25 AM, Brendan Eich wrote:

> * ES3.1 and ES4 will both allow ‘function’ inside control flow  
> statements [directly inside an explicit block, not as the lone  
> unbraced consequent statement of an if, while, etc. /be], and it  
> will be hoisted to the top of the block and initialized on block  
> entry (to be compatible with how functions behave in ES3)

What's the behavior of an if/else control flow statement that contains  
a function definition in each explicit block?

if (true) {
	function x() {
		return 1;
} else {
	function x() {
		return 2;

More information about the Es4-discuss mailing list