var date = new Date(); var d = date; d = [ '0' + d.getDate(), '0' + (d.getMonth() + 1), '' + d.getFullYear(), '0' + d.getHours(), '0' + d.getMinutes() ]; alert(); alert(date); 
  • A Date object is placed with the current date and time. Details you can look in the textbook - learn.javascript.ru/datetime - mihdan
  • In the 'd', after all, a reference to the date is put, but in the array, inside, everything is filled up normally - and what was the expected behavior? - Grundy
  • But then, after all, an array is then placed in d - Илья
  • learn.javascript.ru/datetime, everything is read and solved, but now this point in the last problem, I still do not understand - Ilya
  • Just the order of operations such. First, the rows of the first element of the array are added, added to the array, and so on. The array assignment operation in d is the most recent. - Uranus

1 answer 1

The assignment operator in javascript is right associative - this means that the value of the right side is calculated first and only then the result is assigned to the left.

In this case, the values ​​of the array are calculated first, and only then the new value is assigned to the variable d .