我正在研究一个代码补丁,测试总是出现-1,因为如果语句使后面的部分无法访问,返回会这样做吗?我在想,无论ypos的价值是什么,它总会返回-1?
export function showPreview(content: any , xpos: any, ypos: number, ybot: any) {
if (!(ypos > 100 || ypos < 100 || ypos === 100)) {
return -1;
}
hidePreview();
positionPreview(xpos, ypos, ybot);
return 1;
也许你交出NaN
或undefined
或只是'100'
。
var ypos = '100';
if (!(ypos > 100 || ypos < 100 || ypos === 100)) {
console.log(-1);
}