接上昨天的《前端基础知识整理汇总(上)》,这些知识虽然是很基础的,但是对于系统的梳理还是非常有帮助的,也希望这些内容对你有所帮助。

成都创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都网站制作、网站建设、外贸网站建设、四川网络推广、微信小程序开发、四川网络营销、四川企业策划、四川品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联为所有大学生创业者提供四川建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com
Call, bind, apply实现
- // call
- Function.prototype.myCall = function (context) {
- context = context ? Object(context) : window
- context.fn = this;
-
- let args = [...arguments].slice(1);
- const result = context.fn(...args);
- delete context.fn;
- return result;
- }
-
- // apply
- Function.prototype.myApply = function (context) {
- context = context ? Object(context) : window;
- context.fn = this;
-
- let args = [...arguments][1];
- let result;
- if (args.length === 0) {
- result = context.fn();
- } else {
- result = context.fn(args);
- }
- delete context.fn;
- return result;
- }
-
- // bind
- Function.prototype.myBind = function (context) {
- let self = this;
- let args = [...arguments].slice(1);
- return function() {
- let newArgs = [...arguments];
- return self.apply(context, args.concat(newArgs));
- }
- }
原型与原型链
每一个JavaScript对象(null除外)在创建的时候会关联另一个对象,这个被关联的对象就是原型。每一个JavaScript对象(除了 null)都具有的__proto__属性会指向该对象的原型。JavaScript中所有的对象都是由它的原型对象继承而来,而原型也是一个对象,它也有自己的原型对象,这样层层上溯,就形成了一个类似链表的结构,这就是原型链。每一个对象都会从原型"继承"属性。
实例对象和构造函数都可以指向原型, 原型可以指向构造函数,不能指向实例(因为可以有多个实例)。
原型对象有两个属性,constructor 和 __proto__。
- function Person() {}
- var person = new Person();
-
- // 实例原型 === 构造函数原型
- person.__proto__ === Person.prototype // true
- // 原型构造函数 === 构造函数
- Person.prototype.constructor === Person // true
react diff
- React 通过制定大胆的 diff 策略,将 O(n3) 复杂度的问题转换成 O(n) 复杂度的问题;
- React 通过分层求异的策略,对 tree diff 进行算法优化;
- 对树进行分层比较,两棵树只会对同一层次的节点进行比较。
- React 通过相同类生成相似树形结构,不同类生成不同树形结构的策略,对 component diff 进行算法优化;
- 如果是同一类型的组件,按照原策略继续比较 virtual DOM tree。
- 如果不是,则将该组件判断为 dirty component,从而替换整个组件下的所有子节点。
- 对于同一类型的组件,有可能其 Virtual DOM 没有任何变化,如果能够确切的知道这点那可以节省大量的 diff 运算时间,因此 React 允许用户通过 shouldComponentUpdate() 来判断该组件是否需要进行 diff。
- React 通过设置唯一 key的策略,对 element diff 进行算法优化;
- 建议,在开发组件时,保持稳定的 DOM 结构会有助于性能的提升;
遍历对象
对象遍历方法总结:
- for...in:遍历对象自身, 包含继承, 可枚举,不含 Symbol 的属性。
- Object.keys(obj):遍历对象自身, 不含继承,可枚举,不含 Symbol 的属性。【values, entries】
- Object.getOwnPropertyNames(obj):遍历对象自身, 不含继承, 不含 Symbol 的属性, 不管是否可枚举
- Object.getOwnPropertySymbols(obj): 遍历对象自身, 不含继承, 所有 Symbol 的属性, 不管是否可枚举
- Reflect.ownKeys(obj): 遍历对象自身,不含继承,所有键名,不管是否Symbol 和可枚举。
- 对象其他方法:
- JSON.stringify():只串行化对象自身,不含继承,可枚举,不含 Symbol属性。【function,undefined, Symbol会丢失, set、map会处理成空对象】
- Object.assign():只拷贝对象自身,不含继承, 可枚举属性, 不管是否是Symbol 。【全部数据类型属性值】
异步加载脚本
默认情况下,浏览器是同步加载 JavaScript 脚本,即渲染引擎遇到
基本
文件
流程
错误
SQL
调试
- 请求信息 : 2026-02-16 20:46:10 HTTP/1.1 GET : /article/cdhjeij.html
- 运行时间 : 0.0619s ( Load:0.0033s Init:0.0005s Exec:0.0537s Template:0.0044s )
- 吞吐率 : 16.16req/s
- 内存开销 : 2,321.26 kb
- 查询信息 : 12 queries 5 writes
- 文件加载 : 36
- 缓存信息 : 0 gets 2 writes
- 配置加载 : 130
- 会话信息 : SESSION_ID=s9lbe5mjaocanhp2cit2mqu8i1
- /home/wwwroot/jxjierui.cn/index.php ( 1.12 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/ThinkPHP.php ( 4.61 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Think.class.php ( 12.26 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Storage.class.php ( 1.37 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Storage/Driver/File.class.php ( 3.52 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Mode/common.php ( 2.82 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Common/functions.php ( 53.56 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Hook.class.php ( 4.01 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/App.class.php ( 13.49 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Dispatcher.class.php ( 14.79 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Route.class.php ( 13.36 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Controller.class.php ( 11.23 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/View.class.php ( 7.59 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php ( 3.68 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php ( 3.88 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php ( 1.91 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Conf/convention.php ( 11.15 KB )
- /home/wwwroot/jxjierui.cn/App/Common/Conf/config.php ( 2.12 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Lang/zh-cn.php ( 2.55 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Conf/debug.php ( 1.48 KB )
- /home/wwwroot/jxjierui.cn/App/Home/Conf/config.php ( 0.32 KB )
- /home/wwwroot/jxjierui.cn/App/Home/Common/function.php ( 3.33 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php ( 5.62 KB )
- /home/wwwroot/jxjierui.cn/App/Home/Controller/ArticleController.class.php ( 6.11 KB )
- /home/wwwroot/jxjierui.cn/App/Home/Controller/CommController.class.php ( 1.60 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Model.class.php ( 60.11 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Db.class.php ( 32.43 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Db/Driver/Pdo.class.php ( 16.74 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Cache.class.php ( 3.83 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Cache/Driver/File.class.php ( 5.87 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Template.class.php ( 28.16 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php ( 22.40 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Template/TagLib.class.php ( 9.16 KB )
- /home/wwwroot/jxjierui.cn/App/Runtime/Cache/Home/7540f392f42b28b481b30614275e4e55.php ( 13.96 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php ( 0.97 KB )
- /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php ( 5.24 KB )
- [ app_init ] --START--
- Run Behavior\BuildLiteBehavior [ RunTime:0.000005s ]
- [ app_init ] --END-- [ RunTime:0.000024s ]
- [ app_begin ] --START--
- Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000137s ]
- [ app_begin ] --END-- [ RunTime:0.000149s ]
- [ view_parse ] --START--
- [ template_filter ] --START--
- Run Behavior\ContentReplaceBehavior [ RunTime:0.000051s ]
- [ template_filter ] --END-- [ RunTime:0.000069s ]
- Run Behavior\ParseTemplateBehavior [ RunTime:0.003459s ]
- [ view_parse ] --END-- [ RunTime:0.003478s ]
- [ view_filter ] --START--
- Run Behavior\WriteHtmlCacheBehavior [ RunTime:0.000078s ]
- [ view_filter ] --END-- [ RunTime:0.000089s ]
- [ app_end ] --START--
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`pid`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIMIT 1' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( id= ) LIMIT 1
- 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
[ SQL语句 ] : SELECT `id`,`navname` FROM `cx_nav` WHERE ( pid= )
- [8] Undefined index: pid /home/wwwroot/jxjierui.cn/App/Home/Controller/ArticleController.class.php 第 47 行.
- [2] file_put_contents(./App/Runtime/Temp/e6da66469b8076b12c42e06385ff7ca2.php): failed to open stream: Permission denied /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Cache/Driver/File.class.php 第 132 行.
- [8] Undefined index: db_host /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Db.class.php 第 120 行.
- [8] Undefined index: db_port /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Db.class.php 第 121 行.
- [8] Undefined index: db_name /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Db.class.php 第 122 行.
- [2] file_put_contents(./App/Runtime/Temp/39d7031cdb5b1910862656829491747d.php): failed to open stream: Permission denied /home/wwwroot/jxjierui.cn/ThinkPHP/Library/Think/Cache/Driver/File.class.php 第 132 行.

0.0619s
