我想了解爲什麼這兩段代碼不提供相同的輸入,爲什麼第一塊返回'undefined'?在While循環中調用函數
var myFunction = function() {
Math.floor(Math.random() * 2);
};
while(myFunction === 0){
console.log("Test");
myFunction();
}
console.log("Return");
第二件:
var myFunction = Math.floor(Math.random() * 2);
while(myFunction === 0){
console.log("Test");
myfunction = Math.floor(Math.random() * 2);
};
console.log("Return");
你從哪裏返回一個函數?我沒有看到任何函數中的任何return語句。 – abhishek