您的位置:首页 > Web前端 > JavaScript

javascript草稿

2015-08-20 14:01 549 查看
<html>
<body>

<script>
alert(Math.round(100*Math.random()));//算数运算

alert(isNaN("abc"));//数值或者数值字符串返回false,否则为true

var a = "hello,world";
alert(a.length);//javascript调用new Stirng(a)的方式转换为对象,这个对象继承了字符串的方法,并调用处理属性的方法
a.len = 4;//添加一个属性len,同时赋值为4,,随即销毁这个临时对象,这次修改只作用在临时对象中,并未被保持下来
alert(a.len);//调用这个临时对象的时候,len这个属性不存在

//向包装对象String中添加属性len
var s = new String("hello,world");
s.len = 4;
var t =s.len;
alert(t);
alert("hello,world" === s);//false

var book = {
"main title":"JavaScript",
"for":"all audiences"
};
alert(book["main title"]);
alert(book.for);
</script>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: