GUIDE

The road ahead will be long and our climb will be steep

Javascript 参数的优先级

| Comments

1. 全局,function 内

function 内变量使用 var,重名时,局部变量的优先级更高

 1var a1 = 1;
 2(function() {
 3    a1 = 2;
 4    console.log(a1);  // 2
 5})();
 6console.log(a1);  // 2
 7
 8var a2 = 1, a3 = 1;
 9(function() {
10    var a2 = 2, a3;
11    console.log(a2);  // 2
12    console.log(a3);  // undefined
13})();
14console.log(a2);  // 1
15console.log(a3);  // 1

Angular Need Aot

| Comments

Compare with React and Vue

  • React JSX
Before
1const element = (
2  <h1 className="greeting">
3    Hello, world!
4  </h1>
5);
After
1
2
3
4
5
const element = React.createElement(
  'h1',
  {className: 'greeting'},
  'Hello, world!'
);

Nodejs Best Practices

| Comments

Embrace async

Before
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let af = () => promise;
let bf = () => promise;

let cf = () => {
  return af().then(() => {
    return bf().then(result => {
      let t = result;
      return ...;
    })
  });
}

let df = () => {
  cf().then().catch();
}

Mock a Method When Test Express Api

| Comments

I think many guys are using express as they backend service framework, there is a most important thing Test. We should write test for the apis that usually contains a lot of business logics.

Today I want to show my experiences on writing test for express apis.