1. Code
<script>
//1.输出用户名 并存储到一个变量中
var myname = prompt('请输入您的名字');
//2.输出这个用户名
alert(myname);
</script>
2. Results display
1. Input name
2. Output name
3. Supplementary variables
1. The variable is only declared but not assigned, and the output result is undefined.
2. If a variable is not declared or assigned a value, an error will be reported if a variable is used directly.
3. It can also be used without declaring direct assignment.
4. Try not to use name as a variable name.