โ์๊ฒ๋ ๊ฒ๊ณผ ๋๋์
- toLocaleDateString
- js์ split, ๊ทธ๋ฆฌ๊ณ map
- ์ ๋ ฌ..
- .prettierrc ๋นผ๋จน์ง๋ง์
- ES7์ ๋ชฐ๋๋ ๊ณผ๊ฑฐ์ ๋์ผ
๐ฅ๊ทธ๋์ ํด๋ณด๋ ์ ๋ฆฌ
1. toLocaleDateString
MDN ์ฐธ๊ณ
๊ณผ์ ์์ "ko-KR"
, "en-US"
ํ์์ ๋ง๊ฒ ๋ ์ง๋ฅผ ์ถ๋ ฅํ๋ ๋ถ๋ถ์ด ์์๋๋ฐ, Locale ์ ๊ฑฐ๋ฅผ ๋ชฐ๋ผ์ ํ๋ํ๋ getFullYear....ํด์ ์ค์ ํ๊ณ ์์๋ค. ์์ผ์ ์ฌ์ง์ด ํ๊ธ๊ณผ ์์ด 2๊ฐ์ง๋ก ๋ํ๋ด์ผ ํ๋ ๋ฐฐ์ด๋ ๋๊ฐ! ์ฝ๋ ์๋ ๋๋ฐฐ!
์ ๋ฐ๊ฒ ์๋ค๊ณ ์๋ ค์ฃผ์ ๊ฐ์ง๊ตฌ ๋ถ๋ชจ์ปดํฌ๋ํธ์์ type๋ฅผ ๋๊ฒจ์ ์์์์ ํ์ธ ํ ์ ์ฉํด์คฌ๋ค.
// ๋ถ๋ชจ ์ปดํฌ๋ํธ
// ์ฝ๋ ์๋ต
return (
<div className="wrapper">
<DateTime type="ko-KR" />
// ์ฝ๋ ์๋ต
// ์์ ์ปดํฌ๋ํธ
function DateTime({ type }) {
// ๋ด์ฉ ์๋ต
2. js์ split, ๊ทธ๋ฆฌ๊ณ map
์
๋ ฅ๋ฐ์ ๊ฐ์ sortํ๋ ๋ฌธ์ ์๋๋ฐ, ์ผ๋จ String์ Array๋ก ๋ง๋ค์ด์ผ ํ๋ฏ๋ก split
์ ์ฌ์ฉํ๋ค.
split์ ํ๋ฉด ๋ฐฐ์ด ์์ String์ผ๋ก ๋ค์ด์์ ํ
๋ฐ, ๊ทธ๊ฑธ ์ซ์๋ก ๋ณ๊ฒฝํ๊ธฐ ์ํด์๋ map
์ ์ฌ์ฉํด์ผ ํ๋ค. (ํ์ด์ฌ์ ์์ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ์์ง๋ง์)
var a = "1,2,3,4";
var b = a.split(',').map(function(item) {
return parseInt(item, 10);
});
์ถ์ฒ & special thanks to → How to convert a string of numbers to an array of numbers?
3. ์ ๋ ฌ..
ํ์ด์ฌ๊ณผ ํจ๊ปํ๋ ์๊ณ ๋ฆฌ์ฆ ์คํฐ๋ ์ฝ 10๊ฐ์์ฐจ(์ฌ์ง์ด ์งํ์ค) ํ์.. ์ฌํ๋ง ๋จ์๋ค... ์ด๋ฒ ๊ณผ์ ๋ ๋ฐ์ดํฐ์ ์์ด ๊ทธ๋ ๊ฒ ๋ง์ง ์(์๊ฑฐ๋ผ๊ณ ๋ฉ๋๋ก ํ๋จ)์์ ๊ด์ฐฎ์์ง๋ง(?) ์ค์ ์ฝ๋ฉํ ์คํธ์๋ค๋ฉด ์ฝ์ ์ ๋ ฌ๋ก๋ ๋ชปํ๊ฒ ์ง..?ใ ใ ์ ๋ ฌ ์ง์ง ์๊ธฐ์ ์ ๊ผญ ๊ผญ ์ ๋ฆฌ ํด๋ฌ์ผ๊ฒ ๋ค!
๊ทธ๋ฆฌ๊ณ ์์ฒญ๋ ์๊ตฌ ์๊ณ ๋ฆฌ์ฆ์ ์๊ฐํ ์ฌ์ดํธ๋ฅผ ํ์๋ถ๊ป์ ์๋ ค์ฃผ์ จ๋ค!!๐ → https://visualgo.net/ko
4. prettierrc ๋นผ๋จน์ง๋ง์
{
"singleQuote": true,
"semi": true,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all"
}
CRA ํ ๋๋ง๋ค ๊ผญ ํ๋์ฉ ๋์น๋๋ฐ ์ฌ๊ธฐ๋ ๊ฐ์ด ๋ณด๋ฉด์ ์ ์ฑ๊น์๋คใ ใ ! ์ด๋ฐ ์ฌ์ํ๊ฒ ์ฝ๋ฉ์ ์ง์ ๋์ธ๋ค......!
5. ES7์ ๋ชฐ๋๋ ๊ณผ๊ฑฐ์ ๋์ผ
์ฌ์ค ๋ ์ ํ์ผ์ ๋ง๋ค๋ฉด import react~ ๋ฅผ ์ง์ ์ณค(๊ฑฐ๋ ๋ณต์ฌํ)๋ค. ๊ทธ๊ฑธ ์๊ฒ ๋ ํ์๋ค์ด,, ์ผ๋ฅธ extension ๊น์ผ๋ผ๊ณ ์๋ ค์คฌ๋ค. ํน์ ์์ง๋ ๋ฆฌ์กํธ๋ฅผ ์ง์ ์ํฌํธ ํ๋ ๋ถ์ด ๊ณ์ ๋ค๋ฉด ๊ผญ ์ด๊ฑธ ์ค์นํ์ธ์..๐ญ ์ฌ๊ธฐ์์ ํ์ธ ๊ฐ๋ฅ..
๐์ฐธ๊ณ (๊ฐ์ฌํฉ๋๋ค!)
https://opentutorials.org/course/50/175
toLocaleDateString - ์ํ์ฝ๋ฉ
์์ฝ(Summary) ์ฌ์ฉ์์ ๋ฌธํ๊ถ์ ๋ง๋ ์๊ฐํ๊ธฐ๋ฒ์ผ๋ก ๊ฐ์ฒด์ ์๊ฐ์ ๋ฆฌํด ๋ฌธ๋ฒ(Syntax) toLocaleDateString() ์ธ์(Parameters) ์์ ๋ฐํ๊ฐ(Return) string, ์ด์์ฒด์ ์ ์ค์ ๋ ๋ฌธํ๊ถ์ ๋ง๋ ํํ๋ก ์๊ฐ์ ํ
opentutorials.org
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Date
Date - JavaScript | MDN
JavaScript Date ๊ฐ์ฒด๋ ์๊ฐ์ ํ ์ ์ ํ๋ซํผ์ ์ข ์๋์ง ์๋ ํํ๋ก ๋ํ๋ ๋๋ค. Date ๊ฐ์ฒด๋ 1970๋ 1์ 1์ผ UTC(ํ์ ์ธ๊ณ์) ์์ ๊ณผ์ ์๊ฐ ์ฐจ์ด๋ฅผ ๋ฐ๋ฆฌ์ด๋ก ๋ํ๋ด๋ ์ ์ ๊ฐ์ ๋ด์ต๋๋ค.
developer.mozilla.org
Date.prototype.toLocaleDateString() - JavaScript | MDN
The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of this date. The new locales and options arguments let applications specify the language whose formatting conventions should be used and allow to
developer.mozilla.org
https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets
ES7 React/Redux/GraphQL/React-Native snippets - Visual Studio Marketplace
Extension for Visual Studio Code - Simple extensions for React, Redux and Graphql in JS/TS with ES7 syntax
marketplace.visualstudio.com
How to convert a string of numbers to an array of numbers?
I have below string - var a = "1,2,3,4"; when I do - var b = a.split(','); I get b as ["1", "2", "3", "4"] can I do something to get b as [1, 2, 3, 4] ?
stackoverflow.com
'๐๊ณต๋ถ > ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 5์ฃผ์ฐจ -๊ณผ์ 8 (0) | 2021.08.30 |
---|---|
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 4์ฃผ์ฐจ - ๊ณผ์ 7 (0) | 2021.08.23 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 3์ฃผ์ฐจ - ๊ณผ์ 4 (0) | 2021.08.11 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 2์ฃผ์ฐจ -๊ณผ์ 3(2) (0) | 2021.08.08 |
[ํ๋ฆฌ์จ๋ณด๋ฉ์ฝ์ค] 2์ฃผ์ฐจ -๊ณผ์ 3(1) (0) | 2021.08.04 |
๋๊ธ