数据类型
简单数据类型
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>简单数据类型</title>
<script>
var timer = null;
console.log(typeof timer);
</script>
</head>
<body>
</body>
</html>
简单数据类型传参
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>简单数据类型传参</title>
<script>
function fn(a) {
a++;
console.log(a);
}
var x = 10;
fn(x);
console.log(x);
</script>
</head>
<body>
</body>
</html>
复杂数据类型传参
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>复杂数据类型传参</title>
<script>
function Person(name) {
this.name = name;
}
function f1(x) {
console.log(x.name);
x.name = "张学友";
console.log(x.name);
}
var p = new Person("刘德华");
console.log(p.name);
f1(p);
console.log(p.name);
</script>
</head>
<body>
</body>
</html>