为了账号安全,请及时绑定邮箱和手机立即绑定

为什么score=0和score=null与score=""等效呢?

为什么score=0和score=null与score=""等效呢?

qq_迸发激情_0 2017-05-04 17:43:05
<!doctype html><html><head><meta charset="utf-8"><title>无标题文档</title><script type="text/javascript">  function rec(){ var score; //score变量,用来存储用户输入的成绩值。 score = prompt("请输入成绩",score);   if(score>=90) {   document.write("你很棒!"); } else if(score>=75)    {   document.write("不错吆!"); } else if(score>=60)    {   document.write("要加油!");    } else if(score>0&&score<60){ document.write("要努力了!"); }    else  {       document.write("不务正业!"); }   }  </script></head><body><input name="button" type="button" onClick="rec()" value="点击我,对成绩做评价!" /></body></html>
查看完整描述

1 回答

?
子期不遇

TA贡献150条经验 获得超35个赞

0这个可以被认为是0值,可以是false,可以是空;null一般认为是null值;‘’一般认为是空。在不同的场景所代表的意思也不同,建议根据场景选择所需的0、null或者‘’;

查看完整回答
反对 回复 2017-05-04
  • 1 回答
  • 0 关注
  • 1495 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信