javascript6-系统对象
来源:互联网 发布:轩辕世界坐骑进阶数据 编辑:程序博客网 时间:2024/05/12 10:10
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title></title>
</head>
<body>
<scripttype="text/javascript">
// Date 对象
// 记录时间的,时间对象
varnow= new Date();
// alert(now);
// 年份获取
varyear= now.getFullYear();
// alert(year);
// 月份获取 0 ~ 11
varmonth= now.getMonth();
// alert(month);
// 日获取
varday= now.getDate();
// alert(day);
// 星期
varweekday= now.getDay();
// alert(weekday);
// 小时 24小时
varhour= now.getHours();
// alert(hour);
// 分钟
varminute= now.getMinutes();
// alert(minute);
// 秒
varsecond= now.getSeconds();
// alert(second);
// 毫秒
varmillsecond= now.getMilliseconds();
// alert(millsecond);
// 从1970年1月1日到现在的毫秒数
// 时间戳
vartime= now.getTime();
// alert(time);
// 获取到指定时间
var future= new Date(1949, 9, 1, 8, 30, 00);
alert(future);
// string 对象
// 万事万物皆对象
// 创建一个字符串
// var myStr = new String("hello js");
// alert(myStr.length);
// var str = "村雨于文文是天生一对";
// alert(str.length);
// 字符串对象方法:
// charAt();
// 查询某个下标处的字符;
// 必需。表示字符串中某个位置的数字,即字符在字符串中的下标。
// alert(str.charAt(0));
// search();
// 查找,返回值是查找到的位置。
// regexp;正则表达式
// 查找找到第一个出现的字符就返回下标位置, 如果没有找到任何匹配的字符串,则返回-1
// alert(str.search("文文"));
// 字符串拼接
// var str1 = "竖着";
// var str2 = "于";
// var str3 = "文文";
// 字符串是一种特殊形式的数组
// var newStr = str1.concat(str2, str3, "是天生一对");
// var newStr = str1 + str2 + str3;
// alert(newStr);
//indexOf(); 检索
// 竖着于文文是天生一对
// 查找首个出现的字符,返回其下标位置,如果找不到,返回-1
// indexOf(); 也可以应用于数组
// alert(str.indexOf("是"));
// var aa = [1, 5, 2, 4, 6];
// alert(aa.indexOf(4));
// lastIndexOf();
// 检索,从后往前检索,首次出现的字符,返回其下标位置
// str = "问问送货上门啊问问";
// alert(str.lastIndexOf("问问"));
// 字符串分割
// str = "i love u all night";
// split();
// 根据某一字符串来分割字符串,分割之后放到数组中
// var a = str.split(" ");
// alert(a[1]);
// 字符串连接
// join(); 数组的方法
// str = a.join("
- javascript6-系统对象
- JavaScript6
- JavaScript6看上去很美
- 六个漂亮的 JavaScript6 技巧
- 由浅入深JavaScript6基础-语句1
- 由浅入深JavaScript6基础-语句2
- 对象系统
- 系统对象
- JavaScript6里出现了哪些新语法、新特征?
- JavaScript6里出现了哪些新语法、新特征
- 系统对象和对象权限
- GObject对象系统
- GObject对象系统
- GObject对象系统
- GObject 对象系统
- GObject对象系统
- 面向对象系统设计
- Qt元对象系统
- leetcode_c++:链表:Partition List (086)
- 返回指针的函数使用
- Group Anagrams
- 16-07-17 scrollview can host only one direct child
- Hadoop 基础知识---之HDFS篇
- javascript6-系统对象
- java设计模式-单例模式
- 6天通吃树结构—— 第五天 Trie树
- Error configuring application listener of class org.springframework.web.context.ContextLoaderListen
- ArcGIS Engine 10.0 for.NET开发学习笔记(二)
- 学习技能表
- Android学习笔记--消息处理机制
- Retrofit使用场景总结
- hdu 5167 Fibonacci(DFS,剪枝,斐波那契)