Justin's Words


  • Home

  • About

  • Archives
Justin's Words

CSS Hack

Posted on 2015-10-18 | In Front-End |

本篇文章就是为了我去前端笔试面试而写的,参考 CSS hacks 和 Browserhacks。

Read more »
Justin's Words

JavaScript 跨域请求

Posted on 2015-10-14 | In Front-End |

以下是一个 ECMAScript6 版本的 JSONP 方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
let jsonpLoad = (url) => {
let index = 0;
const timeout = 5000;

Element.prototype.remove = function() {
this.parentNode.removeChild(this);
};

return new Promise((resolve, reject) => {
const callback = `__callback${index++}`;
const timeoutID = window.setTimeout(() => {
reject(new Error('Request timeout.'));
}, timeout);

const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = `${url}${!~url.indexOf('?')? '?': '&'}callback=${callback}`;
document.querySelector('head').appendChild(script);

window[callback] = res => {
script.remove();
window.clearTimeout(timeoutID);
resolve(res);
}
});
};
Read more »
Justin's Words

gulp.js 基础

Posted on 2015-09-24 | In NodeJS |

想了解 gulpjs 是什么可以看官网。

引入

我已经写好一个项目的 gulpfile.js,其中用到的 gulpjs 插件包括 gulp-less、gulp-coffee、gulp-util、webpack、gulp-uglify、gulp-rename。

Read more »
Justin's Words

使用 sftp 与服务器进行文件传输

Posted on 2015-09-14 | In Linux |

使用 sftp 与服务器进行文件传输比 ftp 要安全。

登陆

1
sftp username@remote_hostname_or_IP
Read more »
Justin's Words

ECMAScript6 Promise

Posted on 2015-09-08 | In Front-End |

Promise 解释

The Promise object is used for deferred and asynchronous computations.

Read more »
Justin's Words

JavaScript 继承

Posted on 2015-09-07 | In Front-End |

call & apply

call 和 apply 作用基本相同,都可以让一个对象引用另一个对象或它的方法,两者唯一的不同是 call 接受函数参数的方式是一个个列出来,apply 接受函数参数的方式是一个数组。

Read more »

Justin's Words

AsyncJS 基础

Posted on 2015-09-06 | In Front-End |

AsyncJS 指的是 async,是一个异步处理的组件。

Series 和 Limit 的区别

  • Series - the same as but runs only a single async operation at a time
  • Limit - the same as but runs a maximum of limit async operations at a time
Read more »
Justin's Words

Express 基础

Posted on 2015-09-01 | In NodeJS |

创建 package.json

1
2
3
4
5
6
7
8
9
10
11
12
{
"name": "express-basis",
"main": "service.js",
"dependencies": {
"body-parser": "^1.13.3",
"express": "^4.13.3",
"jade": "^1.11.0",
"mongoose": "^4.1.4",
"morgan": "^1.6.1",
"underscore": "^1.8.3"
}
}
  • body-parser 是为了取得 req.body.param。
  • express 是框架。
  • jade 是渲染引擎。
  • mongoose 操作 MongoDB。
  • morgan 输出访问信息。
  • underscore 是神器。
Read more »
Justin's Words

CommonJS 基础

Posted on 2015-08-31 | In Front-End |

CommonJS 被设计来针对服务端,不过现在可以通过 Browserify 转变给客户端使用,如有这方面的需求,更建议使用 webpack。

1
browserify .\main.js .\foo.js -o .\bundle.js
Read more »
Justin's Words

AMD 和 RequireJS

Posted on 2015-08-31 | In Front-End |

摘录自:Next Generation JavaScript with AMD and RequireJS

为了解决的问题

1
2
3
<script src="file1.js"></script>
<script src="file2.js"></script>
<script src="file3.js"></script>
Read more »
123…11
Justin Young

Justin Young

You Deserve A Better Life

107 posts
15 categories
54 tags
RSS
Github Twitter
© 2014 - 2019 Justin Young
Powered by Hexo
Theme - NexT.Mist