我有一个数字数组,例如[300,500,700,1000,2000,3000]我想找到最接近的数字,而不是低于给定的数字。例如,搜索2200将返回3000(不是2000)。但是,如果我搜索3200,因为数组中没有更高的东西,它应该返回3000,因为没有其他选择。我可以使用以下方法获得最接近该值的数字:if(sizeToUse==null||Math.abs(this-monitorWidth)但是,我无法使整个过程正常运行。我的完整代码是:$(function(){varmonitorWidth=window.screen.availWidth,sizeToUse=null,upsca