notes

2020. 8. 16.
chmod

  • chmod +rwx <filename> to add permissions.
  • chmod -rwx <directoryname> to remove permissions.
  • chmod +x <filename> to allow executable permissions.
  • chmod -wx <filename> to take out write and executable permissions.

2020. 8. 13.
vscode에서 preview mode로 파일 열리지 않게하기

vscode에서 file explorer나 search를 통해 찾은 파일을 클릭하면 탭에서 italic으로 파일명이 표시되면서 preview mode로 열리고, 같은 방식으로 다른 파일을 열면 preview mode였던 파일은 사라진다. 때때로 그래서 귀찮은 일이 생기는데, 이것을 막으려면 settings.json에 아래를 추가하면 된다.

{
  "workbench.editor.enablePreview": false,
}
{
  "workbench.editor.enablePreview": false,
}

...근데 이렇게 해놓고 무작정 다 열다 보면 램이 터질 수 있다...

2020. 8. 12.
Unexpected use of 'isNaN'. (eslintno-restricted-globals), Argument of type 'string' is not assignable to parameter of type 'number'. ts(2345)

let val = '123'

isNaN(val) // nah! Argument of type 'string' is not assignable to parameter of type 'number'. ts(2345)
isNaN(123) // nah! Unexpected use of 'isNaN'. (eslintno-restricted-globals)
let val = '123'

isNaN(val) // nah! Argument of type 'string' is not assignable to parameter of type 'number'. ts(2345)
isNaN(123) // nah! Unexpected use of 'isNaN'. (eslintno-restricted-globals)

then use

Number.isNaN(val) // yay!
Number.isNaN(val) // yay!

2020. 8. 5.
Array._proto__.length

js array는 object이고 length 프로퍼티를 갖고 있다. 그래서 아래가 가능.

const {length, [0]: first, [length - 1]: last} = [1, 2, 3];

console.log(first, last);  // 1 3
const {length, [0]: first, [length - 1]: last} = [1, 2, 3];

console.log(first, last);  // 1 3

주의: length를 선언해두지 않으면 length - 1을 알 수 없고 lastundefined 되어버림.