首页 >> 文摘 >> JAVASCRIPT

javascript中eval的使用

采集日期:2008-4-23作者:guang_ge(注:本数据由系统自动采集,内容与BHCODE无关)
eval 函数对作为数字表达式的一个字符串进行求值,其语法为:eval(expr)此处 expr 是一个被求值的字符串参数。==============================Eval 函数功能:先解释Javascript代码,然后在执行它用法:Eval(codeString)codeString是包含有Javascript语句的字符串,在eval之后使用Javascript引擎编译。举个小例子: var the_unevaled_answer = "2 + 3";var the_evaled_answer = eval("2 + 3");alert("the un-evaled answer is " + the_unevaled_answer + " and the evaled answer is " + the_evaled_answer);
本周推荐
MORE
热点关注
MORE