javascript第一天数据类型及声明方式

来源:互联网 发布:添加不了网络客户端 编辑:程序博客网 时间:2024/06/07 01:53
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">    <title>Document</title></head><script>// javascript的变量类型及声明方式var $a = 10;var b = "20";var c = '25'var d = 21.50;var e = ['note','pad','c','php'];var f = undefined;//可以用做原生变量var g = null;//对于对象的定义var xm = {name:'lisi',age:20};//js对象的声明方式console.log($a);console.log(b);console.log(c);console.log(d);console.log(e[0]+" "+e[1]);console.log(f);console.log(g);console.log(xm.name+" "+xm.age);//控制台调试变量console.log(1+2+3+"note"+5+7);//6note57//js中逻辑运算中返回的是,最早判断表达式结果的那个值var aa = false;var bb = 6;var cc = true;var dd = (aa || bb);var ee = (aa || bb || cc);var ff = (cc || bb || aa);var gg = (aa && bb);console.log(dd);//6console.log(ee);//6console.log(ff);//trueconsole.log(gg);//false</script><body></body></html>

test.html:19 10
test.html:20 20
test.html:21 25
test.html:22 21.5
test.html:23 note pad
test.html:24 undefined
test.html:25 null
test.html:26 lisi 20
test.html:27 6note57
test.html:37 6
test.html:38 6
test.html:39 true
test.html:40 false

0 0
原创粉丝点击