我想知道是否有更短的方式来写这个:
var x = 1; if(y != undefined) x = y;
我最初尝试过x = y || 1,但那没用.什么是正确的方法去做?
x = y || 1
javascript shorthand
javascript ×1
shorthand ×1