Javascript
generate random id ์ ๋ํ ๊นํ๋ธ ๋ต๋ณ
ID - a unique ID/name generator for JavaScript (github.com) ID - a unique ID/name generator for JavaScript ID - a unique ID/name generator for JavaScript. GitHub Gist: instantly share code, notes, and snippets. gist.github.com I strongly recommend using performance.now().toString(36) instead of Date.now - since it offers a higher precision date (ref: https://developer.mozilla.org/en-US/docs/Web/..
[๋๋ฆผ์ฝ๋ฉ ์๋ฐ์คํฌ๋ฆฝํธ] ๋น๋๊ธฐ promise
https://youtu.be/JB_yU6Oe2eE ์ฃผ์์ ์ฝ๋ฐฑ ์ง์ฅ ์์ // class UserStorage { // loginUser(id, password, onSuccess, onFailure) { // setTimeout(() => { // if ( // (id === "ํ๊ธธ๋" && password === "์๋ฒ์ง") || // (id === "ํฉ์ง์ด" && password === "์ฒญ์ฐ๋ฆฌ") // ) { // onSuccess(id); // } else { // onFailure(new Error("not found")); // } // }, 2000); // } // getRoles(user, onSuccess, onFailure) { // setTimeout(() => { // if (..
[๋๋ฆผ์ฝ๋ฉ ์๋ฐ์คํฌ๋ฆฝํธ]๋น๋๊ธฐ์ ์์ ์ฝ๋ฐฑ์ง์ฅ
https://youtu.be/s1vpVCrT8f4 index.js class UserStorage { loginUser(id, password, onSuccess, onFailure) { setTimeout(() => { if ( (id === "ํ๊ธธ๋" && password === "์๋ฒ์ง") || (id === "ํฉ์ง์ด" && password === "์ฒญ์ฐ๋ฆฌ") ) { onSuccess(id); } else { onFailure(new Error("not found")); } }, 2000); } getRoles(user, onSuccess, onFailure) { setTimeout(() => { if (user === "ํ๊ธธ๋") { onSuccess({ name: "ํ๊ธธ๋", role: "์๋ฒ..
![[์๋ฐ์คํฌ๋ฆฝํธ ์ค๊ธ] call, apply, bind](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbIjl2v%2FbtrxEFp8P2d%2FAAAAAAAAAAAAAAAAAAAAACZ6sa6sr34W1XdIibBVPaC1_oxhwOm_46dienx-SpIm%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DDkD9u2oqavWoSyTUZZyAgHhzLPU%253D)
[์๋ฐ์คํฌ๋ฆฝํธ ์ค๊ธ] call, apply, bind
https://youtu.be/KfuyXQLFNW4 call, apply, bind ์๋ฐ์คํฌ๋ฆฝํธ์์์ ํจ์ ํธ์ถ ๋ฐฉ์ function add(a: number, b: number): number { return a + b; } console.log(add(10, 20)); console.log(add.apply(null, [10, 20])); console.log(add.call(null, 10, 20)); console.log(add.bind(null, 10, 20)()); call, apply, bind : ํจ์ ํธ์ถ ๋ฐฉ์๊ณผ ๊ด๊ณ์์ด this๋ฅผ ์ง์ ํ ์ ์์ javascript์ ํจ์๋ ๊ฐ์ ์์ ๋ง์ this๋ผ๋ ๊ฒ์ ์ ์ํ๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก this๋ window์ด์ง๋ง this๋ ๊ฐ์ฒด ๋ด๋ถ, ๊ฐ์ฒด ๋ฉ..

node.js ์ด์ฉํด์ ํ๋ก ํธ์๋ ๊ฐ๋ฐ ํ๋ก์ ํธ ์์ฑํ๊ธฐ
์ฐธ๊ณ : [Node.js ์ฝ๋๋ฉ] 1.์ค๋ฆฌ์ํ ์ด์ | ๊น์ ํ ๋ธ๋ก๊ทธ (jeonghwan-kim.github.io) ํ๋ก ํธ์๋ ๊ฐ๋ฐํ๊ฒฝ์ ์ดํด: NPM | ๊น์ ํ ๋ธ๋ก๊ทธ (jeonghwan-kim.github.io) 1. ๊ฐ๋ฐ์ ์งํํ ์ ๋นํ ๋นํด๋ ํ๋ ๋ง๋ค๊ธฐ ์๋ ์์๋๋ก ์์ฑํ๊ธฐ npm init ํ๋ก์ ํธ ์์ฑ ๋ช ๋ น์ด๋ก, ํ๋ก์ ํธ์ ๋ฉํ ์ ๋ณด๋ฅผ ์ ๋ ฅํ ์ ์๋ ํ๋ฉด์ด ์ ๊ณต๋๋ค. ์๋์ ๊ฐ์ด ๋ฌ๋ค npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help init` for d..
![[๊ธฐ์ด ์๋ฐ์คํฌ๋ฆฝํธ] ๋๋ฆผ์ฝ๋ฉ by ์๋ฆฌ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ธฐ์ด ๊ฐ์ (ES5+) ์๋ฆฌ์ฆ ์ ์ฃผํ ๊ธฐ๋ก](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbdsJWY%2Fbtrw6V1VIjz%2FAAAAAAAAAAAAAAAAAAAAAMH71PFsk8_tsAFKcLbFNEcxCC2e7QsFoTR8xrC88ns4%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3D%252B96xFl2AQkKHIoz%252BzjrlknPw00s%253D)
[๊ธฐ์ด ์๋ฐ์คํฌ๋ฆฝํธ] ๋๋ฆผ์ฝ๋ฉ by ์๋ฆฌ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ธฐ์ด ๊ฐ์ (ES5+) ์๋ฆฌ์ฆ ์ ์ฃผํ ๊ธฐ๋ก
https://youtu.be/tJieVCgGzhs ** ์๋ฆฌ๋ ์์ ๋ด์ฉ + ๊ฐ์ธ์ ์ผ๋ก ํ์ตํ ๋ถ๋ถ์ ์์ด ํฌ์คํ ์ ์์ฑํ๋ฏ๋ก, ์์ ํ๋ฆ ๋ฐ ๋ด์ฉ๊ณผ ํฌ์คํ ์ด ์์ ํ๊ฒ ์ผ์นํ์ง๋ ์์ต๋๋ค. (์ฝํ ์ธ ์ค๋ฅ ์ง์ ํ์) ํต์ฌ ๊ฐ๋ : 'defer' ์ 'use strict' ์๋ฐ์คํฌ๋ฆฝํธ ๊ณต์์ฌ์ดํธ๋ ์ดํฌ๋ง http://ecma-international.org/ Welcome to Ecma International Welcome Ecma International is an industry association founded in 1961, dedicated to the standardization of information and communication systems. We are also here: Si..
![[์ค๊ธ ์๋ฐ์คํฌ๋ฆฝํธ] ์ฌ๋ณผ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbrD5nu%2Fbtrxb9q62q2%2FAAAAAAAAAAAAAAAAAAAAAPhrg936FVe3mwInRw6GYXzrBDbUZgtELu-TpD3p3Zll%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DlYbu45%252FBJxqAe3Rkrftt615PIrc%253D)
[์ค๊ธ ์๋ฐ์คํฌ๋ฆฝํธ] ์ฌ๋ณผ
https://youtu.be/4_WLS9Lj6n4 **์ฝ๋ฉ์๋ง๋์ ์ ํ๋ธ ๋ฌด๋ฃ ๊ฐ์ข๋ฅผ ๋ณด๊ณ ํ์ตํ ํฌ์คํ ์ ๋๋ค. ๊ฐ์ฒด ํ๋กํผํฐ ํค๋ ๋ฌธ์์ด.. ์ฌ๋ณผ์.. [์ ์ผํ ์๋ณ์] const a = Symbol(); //new๋ฅผ ๋ถ์ด์ง ์๋๋ค. const symA = Symbol(); const symB = Symbol(); console.log(symA); //Symbol() console.log(symB); //Symbol() console.log(symA == symB); //false console.log(symA === symB); // false ์ฌ๋ณผํ์ ์ ์ผ์ฑ์ ๋ณด์ฅํด์ค๋ค. const id = Symbol('id'); ์ฌ๋ณผ ๋ค์ ์๊ดํธ์ ์ค๋ช ์ ๋ฃ์ด์ฃผ๋ฉด ์ข๋ค. ๋ค์ด๊ฐ๋ ๋ฌธ์์ด ์ค๋ช ์ ์ด๋ ํ ์ํฅ๋ ..
![[์ค๊ธ ์๋ฐ์คํฌ๋ฆฝํธ] ๊ฐ์ฒด ์ฐธ์ด, ๊ฐ์ฒด ๋ณต์ฌ, ๋ฐฐ์ด ์ปจํธ๋กค ์ฌํ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbR2zrv%2Fbtrxb01wMWA%2FAAAAAAAAAAAAAAAAAAAAAFjFaVadjJ-T-Ue9TOKUMF7VpmGCftUzFpAmM6ur1grh%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1759244399%26allow_ip%3D%26allow_referer%3D%26signature%3DME6AniCNr1Sb%252F%252FMf1QPx97Fpmio%253D)
[์ค๊ธ ์๋ฐ์คํฌ๋ฆฝํธ] ๊ฐ์ฒด ์ฐธ์ด, ๊ฐ์ฒด ๋ณต์ฌ, ๋ฐฐ์ด ์ปจํธ๋กค ์ฌํ
https://youtu.be/4_WLS9Lj6n4 https://youtu.be/9tbjjZb65ng ** const user = { name:'Mike', age:30 } ์์ ๊ฐ์ด user๋ผ๋ ๊ฐ์ฒด๊ฐ ์์ ๋, ๋ณต์ (๊น์ ๋ณต์ฌ)๋ฅผ ํ๊ธฐ ์ํด์ const cloneUser = user; ์์ ๊ฐ์ด ์์ฑํ๋ฉด ๊ธฐ๋ํ๋ ํจ๊ณผ(๊ฐ์ฒด๋ฅผ ๋ณต์ฌํด์ ๋ฃ๋๋ค)๋ฅผ ์ป์ ์ ์๋ค.(์์ธ: ์๋ ์บก์ฒ ์ฐธ๊ณ ) ์๋ ์บก์ฒ๋ฅผ ์ฐธ๊ณ ํ๋ฉด ์ ์ ์๋ฏ์ด cloneUser๋ ํ์ ๋ด๊ธด user๋ฅผ ๋ํผ๋ฐ์คํ๋ ๋ํผ๋ฐ์ค ๋ณ์๊ฐ ๋๋ค.(์์ ๋ณต์ฌ)(๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ ๊ฐ์ด ๋ค์ด๊ฐ๋ค) ๋ฐ๋ผ์ cloneUser.age=44; ์์ผ๋ก cloneUser์ ํ๋กํผํฐ ๊ฐ์ ๋ฐ๊พธ์ด๋ฒ๋ฆฌ๋ฉด user.age์ ๋์ด๋ ๋๊ธฐํ๋์ด ๋ณ๊ฒฝ๋๋ ๊ฒ์ ์๋ ์์ ๋ฅผ ํตํด ..
[์๋ฐ์คํฌ๋ฆฝํธ] ๋์ ์์ฑ
[Javascript] ๋์ ์์ฑํ๊ธฐ (๋๋ค ์ซ์, Random Number) - ์ด์ ์ค๋ ๋ด์ผ (tistory.com) [Javascript] ๋์ ์์ฑํ๊ธฐ (๋๋ค ์ซ์, Random Number) Javascript๋ก ๋์๋ฅผ ์์ฑํ๋ ๋ฐฉ๋ฒ์ ์๊ฐํฉ๋๋ค. Math.random() ๋ฒ์๋ฅผ ์ง์ ํ ๋์ ์์ฑํ๊ธฐ 0~9 0~10 0~99 0~100 1~10 2~5 ๋์ ์์ฑ ํจ์ ๋ง๋ค๊ธฐ (๋ฒ์ ์ง์ ) min