Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何验证参数是否存在于查询字符串中或不在 node.js 中?
我正在这样验证
if(prm1 == null) return error
但实际上在 console.log(prm1) 中说 undefined..
如何准确验证这一点?
如果参数不存在于您的 queryString 中,则返回为undefined. 该参数不会返回null,因为它没有被初始化。
undefined
null
试试这个 :
if(typeof prm1 != 'undefined') return "error";