浏览器存储

本地存储相关的东西主要涉及到4个,Cookie, localStorage, sessionStorage, indexDB。简单列一张表哥来区分一下他们到分别。

Read more »

Chrome devtools 工作原理

So many books, so little time. - Frank Zappa

面试的时候被问到Chrome devtools的工作原理没答上来,之后专门学习了一下,写本文梳理下知识点。

Read more »

high performace javascript overview

最近看完了高性能javascript,粗略的回顾一下各章知识点。由于看到是英文原版,有些翻译成中文的内容可能不太准确,附上原文做参考。
因为这本书是2010年写的,很多内容不适合当代浏览器,比如第四章讲到的循环算法Duff’s Device, 实测在chrome浏览器中不适用。还有文末提到的构建工具和性能测试工具,都很旧了,所以谨慎参考。

Read more »

Javascript 时间时区大杂烩

Read not to contridict and confute; nor to believe and take for granted; nor to find talk and discourse; but to weigh and consider.

以前从来没有认真钻研过JS中Date的时间时区细节,因为工作中遇到了前端页面设置时间,实际保存早/晚了一天的情况,专门花时间学习了相关知识点,谨以此文作学习笔记。

Read more »

温故而知新 - js事件流机制

Trying to understand some people is like trying to pick up turd by the clean end.

事件是javascript一个至关重要的部分,通过派遣/监听事件,可以实现很多动态功能。通过对事件机制的重温,总是能重新刷新一些曾经模糊的知识点。特别写此文给自己加深印象, 如有错误欢迎指正!

以下文章皆以click事件为例:

事件流机制

事件传递过程

事件从 用户行为触发执行完毕 共有三个状态: 捕获(1) - 抵达target元素(2) - 冒泡(3),由事件对象的eventPhase属性标识。看图:

Read more »

浅谈javascript中的原型和继承

How to travel in time? read. How to feel time? Write.

前几天仔细的看了看javascript的原型模式和基于原型的继承, 今天就对其作一个简单的总结作为读书笔记。

什么是原型

说原型之前,我们先来说说函数吧。

Read more »

理解javascript this关键字的在不同情况下的表现

The best time for new beginnings is now

this的指向问题在javascript中一直比较困扰我。 一下总结了几种情况下this分别指向的内容。 总的来说就是根据执行环境或函数的执行方式不同,this的值有所不同。
这里假设执行环境是在浏览器端,所有的全局对象都是指window对象

Read more »

understanding express(2)之expressJS接收和处理http请求过程

Have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary

今天来了解整个接收和处理请求的过程。

上一章说了当接收到一个请求的时候是通过这个函数 app.handle(req, res, next); 来处理请求的。今天来说一下具体一个请求的处理过程。

收到请求会执行app.handle(req, res, next),具体代码如下:

Read more »

understanding expressJS (1)

Working like don’t need money, dancing like no one’s watching, love like never get hurt

这里主要了解一下启动一个express 应用的过程

//express.js
function createApplication() {
  var app = function(req, res, next) {
    app.handle(req, res, next);
  };

  mixin(app, EventEmitter.prototype, false);
  mixin(app, proto, false);

  app.request = { __proto__: req, app: app };
  app.response = { __proto__: res, app: app };
  app.init();
  return app;
}
Read more »

Understanding node process (2)

If you have been broken, mend yourself. Knowing that you will become more beautiful. And always think before you act. an apology cannot repair something you’ve done without thought.

Last week we talked about multi process and process communication. Today we’re going to take a look at its stability.

Having multi processes work together can improve the usage of our cups at some extend. But how it stability is? What if the process exits unexpected?

Read more »