Tom`s BlogTom`s Blog
Home
文章
分类
标签
最新
Home
文章
分类
标签
最新
node 10backend 11GIT 1Game 1Game option 1WWII 1tag E 2common sense 2css 1html 2javascript 4frontend 4nodejs 1http 2
原生与Fetch的HTTP请求

Date: 6/16/2025Category: frontendTag: http, frontend, javascript

原生请求

// 发起GET请求
const xhr = new XMLHttpRequest;
xhr.open('GET', 'http://127.0.0.1:3000?name=tom&password=123456')
xhr.onload = () => {
    console.log(xhr.status)
    if (xhr.status === 200) {
        console.log(xhr.responseText)
    } else {
        console.log(`Error:${xhr.status}`)
    }
}
xhr.send();
// 发起POST请求
const xhr = new XMLHttpRequest;
xhr.open('POST', 'http://127.0.0.1:3000/post/userInfo');
xhr.setRequestHeader('Content-type', 'application/x-www-formurlencoded');
xhr.onload = () => {
    if (xhr.status = 200) {
        console.log(xhr.responseText);
    } else {
        console.error(`Error:${xhr.statis}`);
    }
};
xhr.send(JSON.stringify({
    name: "12312321",
    email: "131123@qq.com"
}))
原型与面向对象

Date: 6/16/2025Category: frontendTag: http, frontend, javascript

一切皆对象

原型和原型链都是来源于对象而服务于对象的概念,所以我们要先明确一点:

JavaScript中一切引用类型都是对象,对象就是属性的集合。

Array类型、Function类型、Object类型、Date类型、RegExp类型等都是引用类型。

也就是说 数组是对象、函数是对象、正则是对象、对象还是对象。

原型与原型链是什么