1.学习网址
2.基础操作
3.基本框架
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>内置对象</title>
</head>
<body>
<!--
string
• charAt(idx) 返回指定位置处的字符
• indexof(Chr) 返回指定子字符串的位置,从左到右。找不到返回-1
• substr(m,n) 返回给定字符串中从m位置开始,取n个字符,如果参数n省略,则意味着取到字符
• substring(m,n) 返回给定字符串中从m位置开始,到n位置结束,如果参数n省略,则意味着取到参数
• tolowerCase() 将字符串中的字符全部转化成小写
• toupperCase() 将字符串中的字符全部转化成大写
• length 属性,不是方法,返回字符串的长度
Math
• Math.random() 随机数
• Math.ceil() 向上取整,大于最大整数
• Math.floor() 向小取整,小于最小整数String
Date
获取日期
。 etFullYear() 年
。 etMonth() 月
。 getDate() 日
。 getHours() 时
。 getMinutes() 分
。 getSeconds() 秒
设置日期
。 setYear()
。 setMonth()
。 setDate()
。 setHours()
。'setMinutes()
。 setSeconds()
。toloacalestring()转换成本地时间字符串
-->
<script type="text javascript">
var str="Hello World";
console.log(str);
console.log(str.substring(3));// 从下标3开始,截取到最后
console.log(str.substring(3,5));// 从下标3开始,到下标5结束
console.log(str.toLowerCase());// 转小写
console.log(str.toUpperCase());// 转大写
//Math.random() 随机数
console.log(Math.random());
//Math.ceil() 向上取整,大于最大整数
console.log(Math.ceil(1.2));
//Math.floor() 向小取整,小于最小整数String
console.log(Math.floor(1.2));
//得到日期对象
var date = new Date();
console.log(date);
// getFullYear() 年
console.log(date.getFullYear());
// getMonth() 月
console.log(date.getMonth()+1);// 0~11
// getDate() 日
console.log(date.getDate());
// getHours() 时
console.log(date.getHours());
// getMinutes() 分
console.log(date.getMinutes());
// getseconds() 秒
console.log(date.getSeconds());
var mstr = date.getMinutes()< 10 ?"Q"+date.getMinutes(): date.getMinutes();
var dateStr = date.getFullYear()+"-"+(date.getMonth() +1) + "-" + date.getDate()+" " + date.getHours()+":"+ mstr;
console.log(datestr);
//时间本地化
console.log(date.tolocalestring())
</script>
</body>
</html>