-
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array对象 </title>
<script type="text/javascript">
var myarr1= ["我","爱","你"];
document.write(myarr1.reverse());
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array对象 </title>
<script type="text/javascript">
var myarr1= new Array("86","010")
var myarr2= new Array("84697581");
var myarr3= myarr1.concat(myarr2);
document.write(myarr3.join("-"));
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Array对象 </title>
<script type="text/javascript">
var myarr1= new Array("010")
var myarr2= new Array("-","84697581");
document.write(myarr1.concat(myarr2));
</script>
</head>
<body>
</body>
</html>
查看全部 -
数组方法:
concat() 连接两个或更多的数组,并返回结果。
join() 把数组的所有元素放入一个字符串,元素通过指定的分隔符进行分隔。
pop() 删除并返回数组的最后一个元素。
push() 向数组的末尾天机一个或更多元素,并返回新的长度。
reverse() 颠倒数组中元素的顺序。
shift() 删除并返回数组的第一个元素。
slice() 从某个已有的数组返回选定的元素。
sort() 对数组的元素进行排序。
splice() 删除元素,并向数组添加新元素。
toSource() 返回该对象的源代码。
toString() 把数组转为字符串,并返回结果。
toLocaleString() 把数组转换为本地数组,并返回结果。
unshift() 向数组的开头添加一个或更多元素,并返回新的长度。
valueOf() 返回宿主对象的原始值。
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
document.write(Math.round(Math.random()*10-1));
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
document.write(Math.round(3.3) + "<br>");
document.write(Math.round(-0.1) + "<br>");
document.write(Math.round(-9.9) + "<br>");
document.write(Math.round(8.9) + "<br>");
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
document.write(Math.floor(3.3) + "<br>");
document.write(Math.floor(-0.1) + "<br>");
document.write(Math.floor(-9.9) + "<br>");
document.write(Math.floor(8.9) + "<br>");
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
document.write(Math.ceil(3.3) + "<br>");
document.write(Math.ceil(-0.1) + "<br>");
document.write(Math.ceil(-9.9) + "<br>");
document.write(Math.ceil(8.9) + "<br>");
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript">
var mystr="Hello.World!";
document.write(mystr.substr(6) + "<br />");
document.write(mystr.substr(0,5) );
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>string对象</title>
<script type="text/javascript">
var mystr="Hello World!"
document.write(mystr.substring(6) + "<br />");
document.write(mystr.substring(0,5) );
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript">
var mystr="86-010-85468578";
document.write(mystr.split("-") + "<br />");
document.write(mystr.split("") + "<br />");
document.write(mystr.split("", 3) );
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>string对象 </title>
<script type="text/javascript">
var mystr="Hello World!"
document.write(mystr.indexOf("o", mystr.indexOf("o")+1));
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>string对象 </title>
<script type="text/javascript">
var mystr="I love JavaScript!"
document.write(mystr.charAt(mystr.length-1));
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>string对象 </title>
<script type="text/javascript">
var message="I love JavaScript!";
var mychar= message.toLowerCase();
document.write("小写为:"+mychar+"<br>");
mychar= message.toUpperCase();
document.write("大写为:"+mychar+"<br>");
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>日期对象 </title>
<script type="text/javascript">
var mydate=new Date();
document.write("当前时间:"+mydate.getTime()+"<br>");
mydate.setTime( mydate.getTime() + 2* 60 * 60 * 1000);
document.write("推迟二小时时间:" + mydate);
</script>
</head>
<body>
</body>
</html>
查看全部
举报