const dns=require('dns')
const dnslookup=(address)=>{
var a;
dns.resolve4(
address,
(err,addresses)=>{a=addresses}
)
return a
}
console.log(dnslookup('google.com'))
我想在调用dnslookup函数后得到addresses数组的值,传递给变量a。为何得到的结果总是undefined?
javascript@linux:~/test$ node dnslookup.js
undefined
跃然一笑
相关分类