1. eval的用法?
- eval() 函数可以用来计算某个字符串,并执行其中的javascript代码。其语法eval(string);
- 如果传入的参数不是字符串,则直接返回这个参数。
2.eval在什么时候使用?
- 当我们预先不知道执行什么语句,只有条件和参数给定时才知道执行什么语句
- demo
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#box{
width: 406px;
height: 500px;
border: 1px solid black;
margin: 50px auto;
}
#screen{
width: 100%;
height: 100px;
font: 20px ;
text-align: right ;
}
#top,#bottom {
width: 100%;
height: 49px;
border-bottom: 1px solid black;
float: left;
}
#number{
width: 306px;
float: left;
}
#mark{
width: 100px;
float: left;
}
#numbe