Examining the javascript code below:
<script type="text/javascript">
$(function () {
var currentDateTime = new Date();
var oneYear = new Date();
oneYear.setYear(oneYear.getYear() + 1);
alert(currentDateTime + "_" + oneYear);
});
</script>
The expected output of the alert should be the current datetime and the datetime one year from now. However, the actual result in the alert is: "Fri Oct 22 2010 14:17:31 GMT-0400 (Eastern Daylight Time)_Thu Oct 22 0111 14:17:31 GMT-0400 (Eastern Daylight Time)". This shows that instead of adding "1" to the Year correctly, it displays '0111'.
This raises the question: What exactly is happening here? How did the year turn into '0111'?