CV肉饼王

Talk is cheap. Show me the code.

0%

一、使用数组sort方法对数组元素随机排序,并取指定长度的元素

1
2
3
4
5
6
7
Array.prototype.shuffle = function (n) {
var len = this.length,
num = n ? Math.min(n, len) : len,
arr = this.slice(0);
arr.sort(function (a, b) { return Math.random() - 0.5; });
return arr.slice(0, num - 1);
};
阅读全文 »

一、String中支持正则的方法:

1.match:返回包含一个/所有匹配结果的数组,没有则返回null

语法:

1
str.match(regexp)

非全局模式:返回和exec()相同结果。一个数组,其中只有第一个匹配项,额外的属性index表示匹配结果在原字符串中的索引,input属性表示被解析的原始字符串

阅读全文 »

不知不觉又是一年,猛然回想,竟然想不出自己这一年都做了哪些事,只能先去翻翻微信朋友圈,看每个月自己都分享了些什么,然而结果大多数都是豆瓣影评,今年除了看了海量的电影(每周2~3部),似乎并没有太多值得记录的,回过神来,这才觉得人生匆匆,转瞬即逝啊,还是应该给自己的人生作个小结,对来年有个规划。

阅读全文 »

Git Submodule 是一个很好的多项目使用共同类库的工具,他允许类库项目做为repository,子项目做为一个单独的git项目存在父项目中,子项目可以有自己的独立的commit,push,pull。而父项目以Submodule的形式包含子项目。

阅读全文 »

1. 配置SSH安全访问密钥,关闭密码登录

a.参考SecureCRT密钥连接Linux,使用SecureCRT在本机生成公私密钥
b.在VPS对应的用户目录下,新建.ssh文件夹,并上传公钥,然后更名为authorized_keys,并修改权限,如下

阅读全文 »

方式一:原型链继承(prototype模式)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Parent (name) {
this.name = name
this.colors = ['red','green']
}

Parent.prototype.getName = function () {
console.log(this.name)
}

function Child (age) {
this.age = age
}

Child.prototype = new Parent()
Child.prototype.constructor = Child

var child1 = new Child ('20')
console.log(child1.getName) // ƒ () {console.log(this.name)}
var child2 = new Child ('20')
child2.colors.push('blue')
console.log(child1.colors) //['red','green','blue']
console.log(child2.colors) //['red','green','blue']
阅读全文 »

一、安装nvm-windows,方便node版本切换

1
2
3
nvm list              #查看已安装的版本
nvm install 6.11.0 #安装Node.js 6.11.0,因为@angular/cli需要6.9版本以上支持
nvm use 6.11.0 #切换到新安装的版本
阅读全文 »

JS中的数据类型

5种基本数据类型:Number、String、Boolean、Null、Undefined、Symbol

1种复杂数据类型:Object(Array、Function、Reg、Date…)

阅读全文 »