
JavaScript学习笔记
JS开荒
DF11G_0001
We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
js对url进行编码和解码
Javascript语言用于编码的函数,一共有三个,最古老的一个就是escape()。虽然这个函数现在已经不提倡使用了,但是由于历史原因,很多地方还在使用它,所以有必要先从它讲起。 escape 和 unescape 实际上,escape()不能直接用于URL编码,它的真正作用是返回一个字符的Unicode编码值。比如"春节"的返回结果是%u6625%u8282,也就是说在Unicode字符集中,"春"是第6625个(十六进制)字符,"节"是第8282个(十六进制)字符。 它的具体规则是,除了ASCI转载 2021-11-09 18:37:01 · 902 阅读 · 0 评论 -
JS获取时间并格式化
// get time Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.f.原创 2021-10-13 16:26:34 · 130 阅读 · 0 评论 -
手写Promise
简单版(无法链式调用) const PENDING = 'pending' const FULFILLED = 'fulfilled' const REJECTED = 'rejected' function Promise(executor) { var _this = this this.onFulfilled = [] //事件订阅数组 this.onRejected = [] //事件订阅数组 this.state = PENDING this.valu原创 2021-03-15 21:50:44 · 109 阅读 · 0 评论 -
手写new函数
new函数的本质有以下过程: 创建一个空对象 为空对象进行prototype绑定 执行构造函数的方法,并将this绑定到新创建的对象 返回构造函数返回的对象。如果构造函数没有显式返回,则返回第一步创建的对象。 以上过程来自于MDN官方文档 所以我们进行代码实现 function father(name) { this.name = name this.sayName = function () { console.log(this.name) } }原创 2020-12-20 01:57:34 · 441 阅读 · 1 评论 -
ES5面向对象汇总
理解对象 ECMAScript中没有“类”的概念。 ECMA-262将对象定义为:无序属性的集合,其属性可包含基本值,对象或者函数。 使用创建Object实例的方法创建一个对象: let person = new Object() person.name = 'Faker' person.age = 25 person.job = 'T1 MID' person.sayName = function () { console.log(person.name) } 当然也可以使用对象字面量原创 2020-08-26 16:18:49 · 504 阅读 · 0 评论 -
npm种种
npm -v //查看npm版本 npm install -g nrm //下载nrm nrm ls //查看所有nrm源(星号为当前源 nrm test taobao //查看taobao镜像延迟 nrm use taobao //将nrm源设置为taobao镜像 nrm current //查看当前使用的源 nrm add *** //手动添加源 nrm del *** //删除源 ...原创 2020-06-28 19:02:58 · 160 阅读 · 0 评论