可以用函数hasOwnProperty来进行判断,如下:
if (result.hasOwnProperty('code') && !result.code) { alertify.alert(result.msg) }