課程
/前端開發
/Node.js
/node建站攻略(二期)——網站升級
return res.redirect('/');里面這個return有什么用啊,我把return刪除了,效果是一樣的,它有啥用呢?????
2017-03-22
源自:node建站攻略(二期)——網站升級 3-4
正在回答
有用啊,可以阻止程序繼續往下走
User.findOne({name:?name},function(err,?user){ if(err)?console.log(err); console.log(user) if(!user)?return?res.redirect('/'); user.comparePassword(password,?function(err,?isMatch){ if(err)?console.log(err); if(isMatch)?{ console.log('Password?is?matched'); return?res.redirect('/'); }else{ console.log('Password?is?not?matched'); } }) })
如果沒有return不管有沒有user都會比較密碼值,多浪費性能
marshall_stan 提問者
沒有用
慕仙4324424
舉報
幫助你深入前后端開發留下的迷惑,為進一步自學打下基礎
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-04-07
有用啊,可以阻止程序繼續往下走
如果沒有return不管有沒有user都會比較密碼值,多浪費性能
2017-03-22
沒有用