Question: Why does the following code result in logging of `b` while `a` is still `undefined`?

```
(function(){ var a=b=5; })();
console.log('b:'+b);
console.log('a:'+a);

```

Answer: 
In JavaScript if you ommit the var keyword before a variable, it will be considered as global.
So here **b** is a global variable and **a** is only a local to that function's scope.
That's why you are getting the error while accessing the **a**.
Never mind, I figured it out myself as it wouldn't let me sleep.

There are 2 assignments happening within the IIFE whereas only 1 declaration.

The statement `var a=b=5;` declares the variable `a` with `var` but simply does assignment for the other variable `b`.
`b` is actually never declared here, just assigned - making it a *global variable*. 

Hence `b` is accessible to the log statement *outside* the function, which prints its value as `5`.

In other words, under 'strict' mode, the code will look like this: 

```
(function() {
   'use strict';
   var a = window.b = 5;
})();

console.log(b);

```