Have a look at this snippet:
let first = 1;
function second() {
console.log(2);
}
console.log(first, second()); // 2 1
I expect it to print 1 2 in order instead of 2 1. Why function second is executed first?
I observe if both the arguments to console.log are functions, the order in which they are passed is preserved(see below example)
function first() {
console.log(1);
}
function second() {
console.log(2);
}
console.log(first(), second()); // 1 2
Please explain this behavior with relevant resources.