Too much flexibility usually means you can achieve same goal through variant ways. My point of view, that can only bring confusion. I guess that is one reason why software engineering stress so much on convention like naming convention and coding convention.
var person = {name:'henry', gender:'m'};
The code define a variable, person. Obviously, here person is an object. So we can access its name property through:
person.name
Well, and you probably know that we can get the same result by calling
person['name'].
For me, that brings nothing but confusion. Let's see another example. The code below works very well:
function func() { return {name:'henry'}; } //you will see Object { name="henry" } in console console.log(func());
This also works as well:
//there is no semicolon!!!!function func() {return {name:'henry'}}//you will see Object { name="henry" } in consoleconsole.log(func())
See the difference? The second code snippet doesn't have semicolon! Javascript will add semicolons for you!
But check this code:
function func() {return{name:'henry'}}//you will see undefinedconsole.log(func())
What do you expect from the above code? You are wrong if you think you still get an object. Actually, you will get undefined! Thanks to the javascript semicolon insertion mechanism, the code is actually like this:
function func() {return ;{name:'henry'}}//you will see undefinedconsole.log(func());
So, i hope you see my point. I don't like too much language flexibility because it helps and even encourages to create error-prone, inconsistent, and confusing code.