跳转至

内部对象

标准对象

Text Only
typeof 123
"number"
typeof "123"
"string"
typeof true
"boolean"
typeof NaN
"number"
typeof []
"object"
typeof {

}
"object"
typeof {}
"object" 

Date

Text Only
      var now=new Date();
      now.getFullYear();//年
      now.getMonth();// 月 0-11
      now.getDate();// 日
      now.getDay();// 星期x
      now.getHours();//时
      now.getMinutes();//分
      now.getSeconds();//秒

      now.getTime();//时间戳
      console.log(new Date(1705031659116));
Text Only
var now=new Date();
undefined
now.getFullYear()
2024
now.getMonth()
0
now.getDate()
12
now.getDay()
5
now.getHours()
11
now.getMinutes()
54
now.getSeconds()
19
now.getTime()
1705031659116
console.log(new Date(1705031659116))
Date Fri Jan 12 2024 11:54:19 GMT+0800 (中国标准时间)
debugger eval code:1:9
undefined 

转换

Bash
var now=new Date(1705031659116)
undefined
now
Date Fri Jan 12 2024 11:54:19 GMT+0800 (中国标准时间)

now.toDateString()
"Fri Jan 12 2024"
now.toGMTString()
"Fri, 12 Jan 2024 03:54:19 GMT" 

JSON

在JavaScript 一切皆为对象、任何is 支持的类型都可以用SON来表示;格式: 对象都用{} 数组都用[] 所有的键值对都是用 key:value

JavaScript
      var user={
          name:"Lucy",
          age:3
      }
      var jsonUser=JSON.stringify(user);//'{"name":"Lucy","age":3}'
      var obj=JSON.parse('{"name":"Lucy","age":3}'); //Object { name: "Lucy", age: 3 }

JSON和js对象是不同的

JavaScript
var obj={name:"Lucy",age:3};
var json='{"name":"Lucy","age":3}';

Ajax

  • 原生的js写法 xhr 异步请求
  • jQuey 封装好的方法 $(“#name").ajax(“)
  • axios 请求