๋ชฉ๋ก2022/01/27 (7)
whatisthis?
https://mywebproject.tistory.com/259?category=875338 javaScript. ์ซ์์ผ๊ตฌ๊ฒ์ - (2) javaScript. ์ซ์์ผ๊ตฌ๊ฒ์ -(1) Bulls and Cows (์ซ์์ผ๊ตฌ) - Rule - - ์ซ์ ์ ์ ํ์ : 10ํ ์ด๋ด - 4์๋ฆฌ์ ์ซ์๋ฅผ ์์๋ก ์ ํจ. - 0์์ 9๊น์ง์ ๋ค๋ฅธ ์ซ์๋ก ๊ตฌ์ฑ๋จ. ์ซ์๋ ๋ง์ง๋ง ์์น๊ฐ ํ๋ฆผ = B(๋ณผ) ์ซ.. mywebproject.tistory.com - ์ง๋๋ฒ์ ์งํํ๋ ์ซ์์ผ๊ตฌ๊ฒ์์ ์น ๋ฒ์ ์ผ๋ก ์์ ํด์ ์ ์ํด๋ณด์๋ค. - ์ด์ ์๋ ์น ์ฝ์์์๋ง ๊ฒ์์ ์งํ ๊ฐ๋ฅํ๋ค. - ๋ณ๊ฒฝ์ฌํญ 1 / index.html๊ณผ style.css ์ถ๊ฐ 2 / html์ inputํ๊ทธ์ button์ผ๋ก button ํด๋ฆญํ ๋๋ง๋ค ์ด๋ฒคํธ๋ฆฌ์ค๋..
์๋ ํ ์คํธ RPG ๊ฒ์ index.html style.css * { margin: 0; box-sizing : border-box; } html { font-family:Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif; font-size: 16px; line-height: 2; color: #1f2d3d; } body { text-align: center; width: 100%; height: 100vh; background-color: #f8f9fb; } body::after { content: "text-RPG"; display: block; margin-top: 50px; color: #463bc1; font-size: 12px; font-w..
์์(inheritance) - ์์์ ๋ถ๋ชจ ์์ฑ์์ ๊ธฐ๋ฅ์ ๋ฌผ๋ ค๋ฐ์ผ๋ฉด์ ์๋ก์ด ๊ธฐ๋ฅ๋ ์ถ๊ฐํ๋ ๊ฒ์ ์๋ฏธ. = ํ์ฅ(extend) function Vehicle(name, speed) { // 1๏ธโฃ Vehicle ์์ฑ์ this.name = name; this.speed = speed; } Vehicle.prototype.drive = function() { // ๋ฉ์๋ ใ ก ํ๋กํ ํ์ ์ ์์ฑ console.log(this.name + ' runs at ' + this.speed) }; const tico = new Vehicle('tico', 50); // Vehicle ์์ฑ์๋ก tico ๊ฐ์ฒด ๋ง๋ฌ tico.drive(); // 'tico runs at 50' function Sedan(name, s..
prototype, __proto__์ constructor์ ๊ด๊ณ prototype๊ณผ constructor๋ ๋ถ๋ชจ์์ ๊ด๊ณ๋ผ๊ณ ์๊ฐํ๋ฉด ๋๋ค. Person.prototype.constructor === Person; ์ด๊ณ , Person.prototype === (Person์์ฑ์๋ก ๋ง๋ค์ด์ง ๊ฐ์ฒด).__proto__; ์ด๊ธฐ ๋๋ฌธ์ (Person์์ฑ์๋ก ๋ง๋ค์ด์ง ๊ฐ์ฒด).__proto__.constructor === Person; ๋ ์ฑ๋ฆฝํ๊ฒ ๋๋ค. ๋ชจ๋ ๊ฐ์ฒด๋ [[Prototype]]์ด๋ผ๋ ๋ด๋ถ ์ฌ๋กฏ(์๋ฐ์คํฌ๋ฆฝํธ ์์ง์ ๋ด๋ถ ๋ก์ง)์ ๊ฐ์ผ๋ฉฐ, ์์์ ๊ตฌํํ๋ ํ๋กํ ํ์ ๊ฐ์ฒด๋ฅผ ๊ฐ๋ฆฌํจ๋ค. [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์๋ ์ง์ ์ ๊ทผ์ด ๋ถ๊ฐํ๋ค. ์ด๋ ํ๋กํ ํ์ ์ฒด์ธ์ ๋จ๋ฐฉํฅ์ ์งํค๊ธฐ ์ํด์๋ค. (๋ง์ฝ ..
๊ฐ์ฒด ์งํฅ ํ๋ก๊ทธ๋๋ฐ(OOP) ex> let date = new Date(); typeof date; // object - ์ง๋ ์๊ฐ Date ๊ฐ์ฒด๋ฅผ new Date()๋ก ์์ฑํ ๊ฒ. Date๋ ๋ถ๋ช ๊ฐ์ฒด๋ผ๊ณ ํ๋๋ฐ, new๋ฅผ ๋ถ์ด๊ณ , ํจ์์ฒ๋ผ ํธ์ถ()์ ํ๋ค. >> ์์ฑ์(constructor) ํจ์ ๐ ์์ฑ์ ํจ์ - ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ํจ์. - ์๋ฐ์คํฌ๋ฆฝํธ์๋ Class๊ฐ ์์ด์, ์์ฑ์ ํจ์๊ฐ ๊ทธ ์ญํ ์ ๋์ ํจ. function Person(name, gender) { this.name = name; this.gender = gender; this.sayHello = function() { alert(this.name + ' said "hello"'); } } ์ฌ๋์ ๋ง๋๋ ์์ฑ์ ํจ์์ด๋ค. ์ฌ๊ธฐ์..
1. Date const time = new Date(); //ํ์ฌ ๋ ์ง+์๊ฐ ์ ์ฅ const time = new Date(2000, 5, 10) // 2000๋ 6์ 10์ผ 0์ 00๋ถ 00์ด new์ ๊ฐ์ฒด๋ฅผ ํจ์์ฒ๋ผ ์ฌ์ฉํ๋ค. ํน์ ๋ ์ง๋ฅผ ์ ์ฅํ๋ ค๋ฉด new Date() ์์ ๋ ,์,์ผ์ ํจ์์ ์ธ์๋ฅผ ๋ฃ๋ฏ์ด ํ๋ฉด ๋๋ค. โ ์ฌ๊ธฐ์, ์(Month)์ ๊ฒฝ์ฐ์๋ -1์ด ๋๋ฏ๋ก 6์์ด๋ฉด 5๋ผ๊ณ ํด์ผํ๋ค. (์ฆ, 1์ = 0) ๐ Date ๊ด๋ จ ๋ฉ์๋ 1) ๋ ์ง.getFullYear() ๋ ์ง.setFullYear(์ฐ๋) - getYear๊ณผ setYear๋ ์์ง๋ง, 2000๋ ์ดํ๋ฅผ ํ์ํ์ง ๋ชปํด์ Full์ด ์ถ๊ฐ๋ getFullYear๊ณผ setFullYear์ด ๋ฑ์ฅํ๋ค. 2) ๋ ์ง.getMonth() ๋ ์ง...
https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Regular_Expressions ์ ๊ท ํํ์ - JavaScript | MDN ์ ๊ท ํํ์์ ๋ฌธ์์ด์ ๋ํ๋ ํน์ ๋ฌธ์ ์กฐํฉ๊ณผ ๋์์ํค๊ธฐ ์ํด ์ฌ์ฉ๋๋ ํจํด์ ๋๋ค. ์๋ฐ์คํฌ๋ฆฝํธ์์, ์ ๊ท ํํ์ ๋ํ ๊ฐ์ฒด์ ๋๋ค. ์ด ํจํด๋ค์ RegExp์ exec ๋ฉ์๋์ test ๋ฉ์๋ , developer.mozilla.org