如何让JS SDK请求时直接暂停线程

我需要写一个排行榜 是循环从服务器取数据的 但是会出现服务器还没返回数据就进入下一次循环
我是这样做的:

$(ouser).each(function(index) {
	user.get(ouser[index]).then(function(userres) {
		query.equalTo("userid", ouser[index])
		query.descending("speed")
			query.first().then(function(object) {
			ouser[index] = userres.get("username")
			lb.push(new Array(ouser[index], object._serverData.speed))
			if (index == ouser.length - 1) {
				while(true) {
					if(ouser.length == lb.length) {
						//逻辑
						break
					} 
				}
			}
		})
	})
})

其中可以保证ouserlb的长度最终会相等
用这个方法 只要服务器没有返回参数 页面干脆就不加载了
怎么样才能让请求“阻塞”线程?

另外一种思路 把所有要请求的数据都保存在数组里再用是不是好一些?

最后我还是迫不得已用了这种方式等待返回值

var a = function() {
    if(已返回) {
        //逻辑
    } else {
        setTimeout(a, 时间)
    }
}
a()

可以了解一下 Promise 或 await,这个算 JavaScript 开发的知识了,和 LeanCloud 关系不大 http://liubin.org/promises-book/