1、变量未定义:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		console.log(a);  // undefined
	</script>
</body>
</html>

 

2、变量定义了但未赋值:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		var a;
		console.log(a);  // undefined
	</script>
</body>
</html>

  

3、函数未传参:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		function show(a){};
		console.log(show());   // undefined
	</script>
</body>
</html>

  

4、只有 return 没有值:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		function show(){
			return;
		};
		console.log(show());   // undefined
	</script>
</body>
</html>

  

5、函数没有返回值:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		function show(){
			
		};
		console.log(show());  // undefined
	</script>
</body>
</html>

  

相关文章:

  • 2021-08-13
  • 2021-08-22
  • 2021-08-28
  • 2022-12-23
  • 2021-12-05
  • 2021-10-23
  • 2021-08-14
  • 2021-05-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2018-03-14
  • 2022-12-23
相关资源
相似解决方案