第一种:
str:第一个命名在alert的上面的时候,第二个在alert下面,就不会发生替换。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>8.08.尚硅谷_JS基础_Number</title>
<script>
//
var str = "hello"
alert(str)
str = 12345
</script>
</head>
<body>
</body>
</html>
效果图:
第二种:
str:第一个命名在alert的上面的时候,第二个也在alert上面,就会发生替换。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>8.08.尚硅谷_JS基础_Number</title>
<script>
//
var str = "hello"
str = 12345
alert(str)
</script>
</head>
<body>
</body>
</html>
效果图: