检查对象是否为非本机方法

| 我目前正在NodeJS中构建一个MVC框架,但是当我检查以查看是否有一种方法存在于控制器中时,我遇到了一个小问题:
var controller = new (this.appManager.getControllerObj(this.route.controller))();
var method     = this.route.method;

if(method in controller)
{
    /*
     * Method exists within controller
     * */
}
但是很明显,对象类型具有本机原型,因此,如果我通过以下方式访问我的网站:
https://localhost/index/__proto__
显然会尝试路由该方法。 现在我知道我可以简单地将特定方法列入黑名单,但是有更好的方法来完成此操作 更新: 这似乎正常工作:
if((method in controller) && !controller.hasOwnProperty(method))
{
    /*
     * Method exists within controller
     * */
}
谢谢     
已邀请:
您可以使用:
controller.hasOwnProperty(method)
Google for hasOwnProperty了解更多信息     

要回复问题请先登录注册