user-img
Language/JS 31
์‚ฐ์ˆ  ํ• ๋‹น ์ฆ๊ฐ ์—ฐ์‚ฐ์ž
1. ์‚ฐ์ˆ  + - x / %(๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ์ž) 2. ํ• ๋‹น // var -> ์žฌ์„ ์–ธ ์žฌํ• ๋‹น ์ „๋ถ€ ๊ฐ€๋Šฅ // let -> ์žฌ์„ ์–ธ ๋ถˆ๊ฐ€ ์žฌํ• ๋‹น ๊ฐ€๋Šฅ let a = 3 a = 5 // ok let a = 3 let a = 2 //Error // const -> ์žฌ์„ ์–ธ ์žฌํ• ๋‹น ์ „๋ถ€ ๋ถˆ๊ฐ€๋Šฅ const a = 3 a =4 //Error 3. ์ฆ๊ฐ let a = 2 console.log(++a) console.log(a) // ํ•ด๋‹น ์ถœ๋ ฅ๋ฌธ ์‹คํ–‰ํ•˜๊ธฐ ์ „์— a ๊ฐ’์— 1์„ ๋”ํ•ด๋ผ (์ถœ๋ ฅ 3 3) console.log(a++) console.log(a) // ํ•ด๋‹น ์ถœ๋ ฅ๋ฌธ ์‹คํ–‰ ํ›„์— a์— 1 ๋”ํ•ด๋ผ (์ถœ๋ ฅ 2 3)
2023.03.31
Language/JS
Type ํ™•์ธ
//๋ฐ์ดํ„ฐ ํƒ€์ž… ํ™•์ธ // console.log(typeof a) // ๊ทผ๋ฐ ์ด๊ฑธ๋กœ๋Š” null, ๋ฐฐ์—ด[] ๊ฐ์ฒด{} ๋Š” ํ™•์ธํ•˜์ง€ ๋ชปํ•œ๋‹ค. // Js์—์„œ๋Š” ํ•จ์ˆ˜๋„ ํƒ€์ž…์œผ๋กœ ์นœ๋‹ค. console.log(typeof 'hello' === 'string') console.log(typeof 123 === 'number') console.log(typeof false === 'boolean') console.log(typeof undefined === 'undefined') console.log(typeof null ==='object') console.log(typeof[] === 'object') console.log(typeof{} === 'object') console.log(typeof function (..
2023.03.31
Language/JS
์ฐธ๊ณผ ๊ฑฐ์ง“
// ์ฐธ๊ณผ ๊ฑฐ์ง“ /* * -- boolean์œผ๋กœ ๋ฐ›์•„๋“ค์—ฌ์งˆ ์‹œ ๊ฑฐ์ง“์œผ๋กœ ๊ฐ„์ฃผ๋˜๋Š” ๊ฒƒ * (1) false * (2) 0, * (3) null, * (4) undefined * (5) NaN * (6) '' -> ๋นˆ ๋ฌธ์ž์—ด * (7) 0n -> Bigint๋ž€ ํƒ€์ž…์œผ๋กœ 0์„ ๋‚˜ํƒ€๋‚ธ๊ฒƒ. * --์ด์™ธ์— ๋ชจ๋“  ์ˆซ์ž ๋ฌธ์ž๋Š” ์ „๋ถ€ ์ฐธ-- * ๋ฐฐ์—ด์€ ๋น„์–ด์žˆ์–ด๋„ ์ฐธ์ž„ * NaN์€ ์ž˜๋ชป๋œ ์ˆ˜ํ•™ ๊ณ„์‚ฐ, ์ž˜๋ชป๋œ ์ˆซ์ž๋ฅผ ์˜๋ฏธํ•œ๋‹ค. * ex) 0/0 ===NaN(์ž˜๋ชป๋œ ์ˆ˜ํ•™ ๊ณ„์‚ฐ), 100/"hi" === NaN (์ž˜๋ชป๋œ ์ˆซ์ž) * */ if(null){ console.log('์ฐธ') } else{ console.log('๊ฑฐ์ง“') }
2023.03.31
Language/JS
thumbnail
Component๊ฐ€ ๋ฌด์—‡์ธ์ง€, Props๋กœ ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ ํ•˜์œ„ ์ปดํฌ๋„ŒํŠธ๋กœ ๊ฐ’ ์ฃผ๊ณ  ๋ฐ›๊ธฐ
1.์ปดํฌ๋„ŒํŠธ : ์žฌ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•œ ๊ฐœ๋ณ„์ ์ธ ์—ฌ๋Ÿฌ ์กฐ๊ฐ UI(User Interface)๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ Component๋กœ ๋‚˜๋‰œ๋‹ค. ์นดํ†ก ํ™”๋ฉด์€ ์œ„์™€ ๊ฐ™์ด 5๊ฐœ์˜ ์ปดํฌ๋„ŒํŠธ๋กœ ๋‚˜๋‰˜๋Š” ๊ฒƒ์ด๋‹ค. ์ปดํฌ๋„ŒํŠธ๋Š” java๋กœ ์น˜๋ฉด ๋งค์†Œ๋“œ ๊ฐ™์€ ๋…€์„์ด๋‹ค. 2. ์ปดํฌ๋„ŒํŠธ์˜ ์ข…๋ฅ˜ (1) ํด๋ž˜์Šคํ˜• ์ปดํฌ๋„ŒํŠธ a. ์“ฐ๊ธฐ ์œ„ํ•œ ์กฐ๊ฑด - React.Component๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ๋ฌด์กฐ๊ฑด ์ƒ์†ํ•ด์•ผ ํ•จ. - render() ๋ผ๋Š” ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๊ณ , ์œ„ ํ•จ์ˆ˜์˜ return ๊ฐ’์—๋‹ค๊ฐ€ ํ•˜๊ณ  ์‹ถ์€ ๋‚ด์šฉ๋ฌผ์„ ์ ์–ด์•ผํ•จ. b. state, lifestyle(์ƒ๋ช… ์ฃผ๊ธฐ)๋ผ๋Š” ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ. c. ํ•จ์ˆ˜ ํ˜• ์ปดํฌ๋„ŒํŠธ๋ณด๋‹ค ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋” ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๋‹จ์ . (2) ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ a. state, lifestyle์ด๋ผ๋Š” ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•จ. ๋”ฐ๋ผ์„œ Ho..
2023.03.24
Language/JS
์ผ์น˜ ์—ฐ์‚ฐ์ž์™€ ๋™๋“ฑ ์—ฐ์‚ฐ์ž
์œ ํ˜• ํ˜•ํƒœ ๋œป ์˜ˆ์‹œ ===(์ผ์น˜ ์—ฐ์‚ฐ์ž) a === b a์™€ b๊ฐ€ type์ด ๊ฐ™์€์ง€ check type์ด ๊ฐ™๋‹ค๋ฉด ๊ฐ’์ด ๊ฐ™์€์ง€๋„ check 1 === 1 // true 1 === "1" // false 1 === true // false ==(๋™๋“ฑ ์—ฐ์‚ฐ์ž) a == b ์—ฐ์‚ฐ์ž๊ฐ€ a,b๋ฅผ ํ˜• ๋ณ€ํ™˜ ํ•ด๊ฐ€๋ฉฐ, ๋‚ด์šฉ๋ฌผ์ด ๊ฐ™์€์ง€๋ฅผ check 0 == 0 // true 0 == [ ] // true 0 == false // true ๋™๋“ฑ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ ์‹œ ํ—ท๊ฐˆ๋ฆฌ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์•„ ๊ฐ€๋…์„ฑ์ด ์ €ํ•˜๋˜๋ฏ€๋กœ, ์ผ์น˜ ์—ฐ์‚ฐ์ž๋ฅผ ๋˜๋„๋ก์ด๋ฉด ์‚ฌ์šฉํ•  ๊ฒƒ!
2023.03.23
Language/JS
thumbnail
Function
**์ œ์ผ ์ค‘์š” ํฌ์ธํŠธ** (1) ํ•จ์ˆ˜ ์ด๋ฆ„๋งŒ ์ ์œผ๋ฉด ๊ทธ๊ฒƒ์€ ํ•จ์ˆ˜ ์ฝ”๋“œ ์ „์ฒด(ํ•จ์ˆ˜ ๋ฐ์ดํ„ฐ)๋ฅผ ์˜๋ฏธ ํ•œ๋‹ค. function A () { return 123 } console.log(A) (2) ํ•จ์ˆ˜์ด๋ฆ„() ๋ผ๊ณ  ์ ์œผ๋ฉด ์ด๊ฒƒ์€ ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ฒ ๋‹ค๋Š” ์˜๋ฏธ์ด๊ณ , ํ•ด๋‹น ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋œ ๊ฒฐ๊ณผ๊ฐ€ ๋ฐ˜ํ™˜๋œ๋‹ค. function A () { return 123 } console.log(A()) 1. ์Šค์Šค๋กœ ํ•ด๋ณด๊ธฐ // hello ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜ ๋งŒ๋“ค์–ด์„œ ํ•จ์ˆ˜ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ, ๊ทธ๋ƒฅ ํ˜ธ์ถœ function hello () { console.log("Hello!") } console.log(hello) hello() // 123์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ ๋งŒ๋“ค์–ด์„œ, ํ•จ์ˆ˜ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ ์‹œ type, ๊ทธ๋ƒฅ ํ˜ธ์ถœ ์‹œ type function getN..
2023.03.23
Language/JS
thumbnail
Object ๊ฐ์ฒด
Java์˜ ๊ฐ์ฒด๋ž‘์€ ๋‹ค๋ฅธ ๋Š๋‚Œ. ์—ฌ๊ธด ํด๋ž˜์Šค๋ผ๋Š” ์„ค๊ณ„๋„๋„ ์—†๊ณ , ๋งค์†Œ๋“œ๋„ ์ €์žฅ ์•ˆํ•จ. C++์˜ Struct๋ž‘ ๋น„์Šทํ•œ ๊ฐœ๋…์ด๋‹ค. ๋ฉค๋ฒ„๋ฅผ key : "Value" ํ˜•์‹์œผ๋กœ ๋„ฃ๋Š”๋‹ค. 1. ํŠน์ง• (1) ๊ฐ์ฒด ๋‚ด๋ถ€์˜ ๋ฉค๋ฒ„๋“ค ์‚ฌ์ด์— ์ •ํ•ด์ง„ ์ˆœ์„œ๊ฐ€ ์—†๋‹ค. ๋”ฐ๋ผ์„œ ์ถœ๋ ฅ ์‹œ ๋ฌด์ž‘์œ„ ์ˆœ์„œ๋กœ ๋‚˜์˜จ๋‹ค. (2) ๋งŒ์•ฝ ๊ฐ์ฒด ๋‚ด๋ถ€์— ๊ฐ™์€ ์ด๋ฆ„์˜ Key๋ฅผ ๋‹ค์‹œ ์„ ์–ธ ํ•œ๋‹ค๋ฉด, ์ œ์ผ ์ตœ๊ทผ์— ์„ ์–ธํ•œ Key์˜ Value ๊ฐ’์œผ๋กœ Value๊ฐ€ ๊ฐฑ์‹  ๋œ๋‹ค. user ={ name = "Quan xiu Min" age = 87 age = 27 } // age ์ถœ๋ ฅ์‹œ 27์ด ๋‚˜์˜จ๋‹ค. 2. ํ˜•์‹ /* Object ๊ฐ์ฒด ์ƒ์„ฑ ๋ฐฉ๋ฒ• 3๊ฐ€์ง€ */ // 1. Object() ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ์‚ฌ์šฉ user = Object() user.name ="SooMin" ..
2023.03.23
Language/JS
JS์—์„œ์˜ ๋ฐฐ์—ด
Java๋ž‘ ๋น„์Šทํ•œ ๋“ฏ /*Array (๋ฐฐ์—ด)*/ // 1. ๋ฐฐ์—ด ์„ ์–ธ ๋ฐฉ์‹ 2๊ฐ€์ง€ // (1) ์ •์‹ ๋ฐฉ์‹ weeks = new Array("Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun") // (2) ๋Œ€๊ด„ํ˜ธ ๋ฆฌํ„ฐ๋Ÿด ๋ฐฉ์‹ weeks =["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"] // 2. ์ถœ๋ ฅ // (1) ๋ฐฐ์—ด ์ „์ฒด ์ถœ๋ ฅ console.log(weeks) // (2) ๋ฐฐ์—ด์˜ ํŠน์ • ์š”์†Œ ์ถœ๋ ฅ console.log(week[0])// Mon ์„ ์ถœ๋ ฅ // (3) ๋ฐฐ์—ด์˜ ๊ธธ์ด ์ถœ๋ ฅ console.log(week.length) ๋ฐฐ์—ด ์ด๋ฆ„ = [ ] ๋ฐฉ์‹์ด ๋Œ€๊ด„ํ˜ธ ๋ฆฌํ„ฐ๋Ÿด์ด๋ผ ๋ถˆ๋ฆฌ๋Š” ์ด์œ . ๊ธฐํ˜ธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์„ ๋ฆฌํ„ฐ..
2023.03.23
Language/JS