0%

手写一些方法

instanceof

1
2
3
4
5
6
function _instanceof(left, right) {
if (left.__proto__ === null || left.__proto__ === undefined) return false;
return left.__proto__ === right.prototype
? true
: _instanceof(left.__proto__, right);
}

new

1
2
3
4
5
6
function factory(fn, ...args) {
let o = {};
o.__proto__ = fn.prototype;
fn.call(o, ...args);
return o;
}

call

1
2
3
4
5
6
7
8
9
10
11
12
Function.prototype._call = function(context, ...args) {
if (typeof this !== "function") {
throw new TypeError(
"Function.prototype._call - what is trying to be bound is not callable"
);
}
const ctx = context || window;
ctx.fn = this;
const result = ctx.fn(...args);
delete ctx.fn;
return result;
};

apply

1
2
3
4
5
6
7
8
9
10
11
12
Function.prototype._apply = function(context, ...args) {
if (typeof this !== "function") {
throw new TypeError(
"Function.prototype._apply - what is trying to be bound is not callable"
);
}
const ctx = context || window;
ctx.fn = this;
const result = ctx.fn(...args[0]);
delete ctx.fn;
return result;
};

bind

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function.prototype._bind = function(context, ...args) {
const ctx = context || window;
const _this = this;
function fn() {}
function result(...argus) {
return _this.apply(this instanceof result ? this : ctx, [
...args,
...argus
]);
}
if (this.prototype) {
fn.prototype = this.prototype;
}
result.prototype = new fn();
return result;
};

记录关于健身的感悟

健身不要自我催眠,说减脂简单增肌难

很多人说增肌期,实际上是全年都是增肌期,从不减脂

实际上就是无法保持低体脂的同时保持高竞技状态 的借口

饮食技巧,可以让你更少的投入获得更高效的运动效果

关于饮食

  1. 控制游离糖摄入,吃高油高钠的食物你很容察觉出来,而且只要量一多你就腻

  2. 尽量吃加工程度低的食物

  3. 能不吃蛋白粉之类的补剂就不要吃,原因不是营养,而是因为纯营养失去的身体满足感,不要违背人的本能

  4. 营养均衡,健康的体魄不是单靠某一营养元素达成的

  5. 咖啡和茶叶是非常好的饮料

  6. 哪怕计算总摄入与消耗,也不要在短时间内吃很多碳水化合物,增加肠胃的负担和囤积脂肪的几率

  7. 多用热带水果代替甜点

  8. 随身携带健康的零食

关于训练

  1. 尽量不要做单关节孤立运动,慢发力运动

  2. 不要照着每组8-12去做,能做几个就做几个,后面如果没力气了却强行做8-12个很有可能动作不正确做的话失去意义而且很危险

  3. 练腿也要练小腿

  4. 不要用助力带腰带这种东西,就像吃饭不用舌头,不是刻意强化了,而是刻意弱化了

  5. 训练不要超过一个小时,容易产生依赖,你被健身了,我们应该享受健身的成果,而不是感觉每天要花时间和精力去维持

  6. 多思考再做动作

  7. 不要以胸三头,背二头这样的方法来划分训练日,时间维护成本高,很容易因为有事耽误而影响训练计划,以运动表现和功能划分训练日

  8. 尽量不要高强度训练下戴耳机,降低感知,比较危险

typeof 特性

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
typeof {} => 'object'
typeof [] => 'object'
typeof null => 'object'
typeof new RegExp() => 'object'
typeof new Date() => 'object'
typeof new String('test') => 'object'
typeof new Number(100) => 'object'

typeof 0 => 'number'
typeof Infinity => 'number';
typeof NaN => 'number';

typeof () => {} => 'function'
typeof class TEST {} => 'function'
typeof new Functiuon() => 'function'

typeof true => 'boolean'

typeof undefined => 'undefined'
typeof document.all => 'undefined'
typeof undeclaredVariable => 'undefined'

typeof 'test' => 'string'

typeof Symbol() => 'symbol'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* @param {string} argument1
* @param {number} argument2 strat where
* @return {string}
*/

// function toCamelCase(str, start = 0) {
// return str
// .split("-")
// .map((v, i) => {
// if (i >= start) {
// return v[0].toUpperCase() + v.slice(1);
// }
// return v;
// })
// .join("");
// }

function toCamelCase(str: string, start = 0): string {
return str.replace(/-(\w)/g, (match, matchItem) => matchItem.toUpperCase())
}

Swiper

Container component

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<div className='swiper-view'>

<div className='swiper-view-container'>

<div className='swiper-view-item'>
......
</div>

<div className='swiper-view-item'>
......
</div>

<div className='swiper-view-item'>
......
</div>

</div>
{/* swiper_view_content结尾处 */}
</div>
{/* swiper_view整体容器结尾处 */}
Read more »