JavaScript variable: var a =(3,4,7);
This question already has an answer here:
It's called comma operator . By wrapping the right hand expression in parentheses we create a group and it is evaluated each of its operands and returns the last value.
From MDN
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.
The comma operator is useful when you want to write a minifier and need to shrink the code.
For instance,
print = () => console.log('add')
add_proc = (a,b) => a + b
function add(a, b){
if(a && b){
print();
return add_proc(a,b)
}
else
{
return 0
}
}
console.log(add(1,2));
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.
Here , Seprates each Digits Ans As it is a Variable So it stores 3 then overlapped by 4 and finally 7 So final output is 7
链接地址: http://www.djcxy.com/p/52938.html上一篇: LINQ之后的下一件大事是什么?