2
I was going through some websites when I came across the following excerpt:
if (console.log(i), i && void 0 !== i.name) {
// code here...
}
I tested it out:
var i = {name: "mizuk"};
if (console.log(i), i && void 0 !== i.name) {
console.log("condição verdadeira!");
}
What I understood from the code was:
// se 'i' não estiver vazio e 'i.name' não tiver o mesmo valor e tipo
// que 'undefined' faça:
What I want to know is:
-> where does 'console.log(i)' fit into all this? , it is part of the condition or it was simply called in the middle of the sentence?
-> if he was called, it’s something common or it’s a gambiarra?
-> if it’s something common, I can perform other functions like this?
Thanks in advance for all the help.
Related: Comma-separated sentence in an IF Javascript would have what purpose? "if (1, 2) {}"
– bfavaretto