如题,今天做了一个探索,得出结果是:
均有打断程序并返回对应值,如果不设置返回值则返回undefined。
设计程序如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="format-detection" content="telephone=no,email=no,adress=no">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>Title</title>
</head>
<body>
<script>
window.onload = ()=>{
const getReturn = ()=>{
console.log("这是程序return前的打印!");
return;
console.log("这是程序return后的打印!");
};
const getReturnFalse = ()=>{
console.log("这是程序return false前的打印!");
return false;
console.log("这是程序return false后的打印!");
};
const getReturn0 = ()=>{
console.log("这是程序return 0前的打印!");
return 0;
console.log("这是程序return 0后的打印!");
};
const getReturnabc = ()=>{
console.log("这是程序return abc前的打印!");
return "abc";
console.log("这是程序return abc后的打印!");
};
let returns = getReturn();
let returnFalse = getReturnFalse();
let return0 = getReturn0();
let returnabc = getReturnabc();
console.log("调用程序后的返回值:returns:"+returns+",returnFalse:"+returnFalse+",return0:"+return0+",returnabc:"+returnabc)
}
</script>
</body>
</html>
运行结果: