I'd like a formal explanation on the stance of visual studio C++ and what it does when you create an array such as:
int a[3] = {1, 2, 3};
and you then do something like:
cout << a[4];
Upon test, it will print out the garbage stored in that memory location. Why does it allow the programmer to do this, while a language like javaScript will prevent the user from doing so?
What's the prevailing philosophy by not making the compiler ban this kind of behavior from the user in C++? Is this something carried over from C?
These are just some minor curiosities that I have, and perhaps the person who answers can tell me where I'd be able to find such information. The answer as to what is happening is not what I'm asking, it's the why that I'm interested in.
Thank you.