Normally, I write my code like this:
var a = document.createElement('div');
var b = document.createElement('div');
a.appendChild(b);
This works. Now I tried to make it more compact:
var a,b;
a = b = document.createElement('div');
a.appendChild(b);
However, this way JS throws an error:
Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
What is happening here?