JS的undefined(未定义的)数据类型
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
// undefined场景1
var a;
console.log(a,typeof a) // undefined 'undefined' #未定义的
// undefined场景2
function foo() {
}
var ret = foo()
console.log(ret) // undefined
</script>
</head>
<body>
<h1>welcome to JS!</h1>
</body>
</html>
![](https://img2022.cnblogs.com/blog/1413093/202206/1413093-20220601195330207-943908015.png)