前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >前端小知识10点(2020.9.13)

前端小知识10点(2020.9.13)

作者头像
进击的小进进
发布2020-09-18 11:17:07
5260
发布2020-09-18 11:17:07
举报

1、ReactClassCompFunctionComp组件的更新/卸载顺序

更新:,从左至右

卸载:,从左至右

2、vscode如何配置「注释后自动切换到下一行」?

① 下载「geddski.macros」插件

② macOS 打开访达—>command+shift+g—>~/Library/Application Support/Code/User/

③ 打开settings.json,将以下json复制到里面

④ 打开keybindings.json,将以下json复制到里面

参考:

https://www.reddit.com/r/vscode/comments/7nlp9k/when_commenting_a_line_move_the_cursor_to_the/

3、git commit --amend的作用?

作用:

将本次commit直接合并到上一次commit

使用:

代码语言:javascript
复制
git commit --amend
git push orgin <分支> -f

注意:

这里必须使用-f,将远程上的commit给挤掉,否则就是两个commit

4、yarn --ignore-engines的作用?

让yarn忽略引擎检查(忽略node版本的差异)

5、mac 启用tab自动补全目录

https://blog.csdn.net/YanceChen2013/article/details/62887705

6、git rebase的作用场景

合并commit

commitC合并到commitB

代码语言:javascript
复制
git log --oneline
6a5a7d1 (HEAD -> master) commitC
6abd377 commitB
9a552a8 commitA
190d021 (origin/master) eject
d550345 Initialize project using Create React App
// 定位到 commitA 的 commitId 上
// 注意哦,是commitA
git rebase -i 9a552a8

此时就跳到了rebasevim界面:

代码语言:javascript
复制
pick 6abd377 commitB
pick 6a5a7d1 commitC

# Rebase 9a552a8..6a5a7d1 onto 9a552a8 (2 commands)

i修改commitCpick->squash

代码语言:javascript
复制
pick 6abd377 commitB
squash 6a5a7d1 commitC

# Rebase 9a552a8..6a5a7d1 onto 9a552a8 (2 commands)

:wq保存并合并

此时就看到commitC被合并到commitB上,但还没完成rebase

代码语言:javascript
复制
git rebase --continue

修改commit message

代码语言:javascript
复制
# This is a combination of 2 commits.
# This is the 1st commit message:

commitB

# This is the commit message #2:

commitC

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
代码语言:javascript
复制
# This is a combination of 2 commits.
# This is the 1st commit message:

将commitC合并到commitB中

# This is the commit message #2:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
代码语言:javascript
复制
git push origin

Done.

移除commit

移除commitA

代码语言:javascript
复制
// 定位到commitA的前一个commit
git rebase -i 190d021

pick修改为drop

代码语言:javascript
复制
pick fabbfb2 commitA
pick 556efde 将commitC合并到commitB中
代码语言:javascript
复制
drop fabbfb2 commitA
pick 556efde 将commitC合并到commitB中

正常情况是只将commitA删除掉,但此时看到git说:

代码语言:javascript
复制
git commit --allow-empty
[detached HEAD 6c0e9a4] 将commitC合并到commitB中
 Date: Sun Sep 6 23:00:46 2020 +0800

git rebase --continue
git push origin -f

此时commitA就被删掉了

7、[].every(item=>item>18) 返回结果?

空数组,直接返回true

代码语言:javascript
复制
[].every(item=>item>18) //true

8、slice和splice的区别

代码语言:javascript
复制
  // slice
  // 1、string的function
  // 2、不影响原str
  const str='123456'
  console.log(str.slice(0, 2)); //12
  console.log(str) //123456

  //splice
  // 1、array的function
  // 2、影响原array
  const arr=[1,2,3,4,5,6]
  console.log(arr.splice(0, 2)); // [1, 2]
  console.log(arr) // [3, 4, 5, 6]

9、git删除远程分支

代码语言:javascript
复制
git push origin --delete <branch>

10、交换数组中的两个元素

代码语言:javascript
复制
  //交换数组中的元素
  const swap = (nums, i, j) => {
    [nums[i], nums[j]] = [nums[j], nums[i]];
  }

  const arr=[1,2,3]
  swap(arr,0,1) //[2, 1, 3]
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-09-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 webchen 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档