Skip to content

Commit 3b53330

Browse files
author
seungwonme
committed
Rename repository from Front-Practice to Web and add CSS and HTML directories
1 parent 78e831d commit 3b53330

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+418
-5466
lines changed

CSS/README.md

Whitespace-only changes.

HTML/README.md

Whitespace-only changes.

JavaScript/1-Data-Type.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Integer
2+
3+
let integer = 2147483647;
4+
let infinity = Infinity;
5+
let negInfinity = -Infinity;
6+
let nan = NaN;
7+
8+
console.log(`integer: [${integer}\ninfinity: ${infinity}\nnegInfinity: ${negInfinity}\nnan: ${nan}`);
9+
10+
// String
11+
12+
let name1 = "seunan";
13+
let name2 = `${name1} babo`; // 백틱을 이용해 문자열을 템플릿화할 수 있다.
14+
15+
console.log(`name1: ${name1}\nname2: ${name2}`);
16+
17+
// Boolean
18+
19+
let isTrue = true;
20+
let isFalse = false;
21+
22+
console.log(`isTrue: ${isTrue}\nisFalse: ${isFalse}`);
23+
24+
// Null & Undefined
25+
26+
let undefinedVariable;
27+
let nullVariable = null;
28+
29+
console.log(`undefinedVariable: ${undefinedVariable}\nnullVariable: ${nullVariable}`);
30+
31+
let a;
32+
a = a ?? 10; // null 병합 연산자, a가 null 또는 undefined일 경우 10을 반환한다.
33+
console.log(`a = a ?? 10: ${a}`);
34+
35+
let numberA = 12;
36+
let numberB = "2";
37+
console.log(`numberA + numberB = ${numberA + numberB}`);
38+
console.log(`numberA + parseInt(numberB) = ${numberA + parseInt(numberB)}`);
39+
console.log(`numberA * numberB = ${numberA * numberB}`);

JavaScript/2-Function.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
funcDeclaration(); // 호이스팅으로 인해 함수 선언문은 호출 가능하다.
2+
// funcExpression();
3+
4+
function funcDeclaration() {
5+
console.log("Run funcDeclaration");
6+
console.log(this.key);
7+
return ("Declaration");
8+
}
9+
10+
const funcExpression = function () {
11+
console.log("Run funcExpression");
12+
return ("Expression");
13+
}
14+
15+
const arrowFunc = () => {
16+
console.log("Run arrowFunc");
17+
return ("Arrow");
18+
}
19+
20+
const arrowFuncOmitReturn = () => "Arrow";
21+
// return문만 있을 경우 중괄호와 return을 생략할 수 있다.
22+
23+
const arrowFuncOmitBrackets = arg => `Arrow ${arg}`;
24+
// 매개변수가 하나일 경우 괄호를 생략할 수 있다. 함수의 몸체가 표현식일 경우 중괄호와 return을 생략할 수 있다.
25+
26+
const testThis = {
27+
name: "seunan",
28+
sayHiDeclaration: function() {
29+
console.log(`Hi, ${this.name}`); // this가 바인딩된다.
30+
},
31+
sayHiExpression: () => {
32+
console.log(`Hi, ${this.name}`); // this가 바인딩되지 않는다.
33+
},
34+
}
35+
36+
testThis.sayHiDeclaration();
37+
testThis.sayHiExpression();
38+
39+
callbackFunc("seunan", () => console.log("Callback"));
40+
41+
// 콜백함수란 함수를 인자로 받아 특정 작업이 끝났을 때 실행시키는 함수를 말한다.
42+
function callbackFunc(name, callback) {
43+
console.log(`Hello, ${name}`);
44+
callback();
45+
}

JavaScript/3-Object.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
let obj = new Object(); // 객체 생성자 함수를 이용한 객체 생성
2+
let obj1 = {}; // 객체 리터럴을 이용한 객체 생성
3+
4+
let obj2 = {
5+
key: "value", // key : value 형태로 객체의 속성을 정의, object property
6+
key1: "value1",
7+
key2: true,
8+
key3: undefined,
9+
key4: [1, 2, 3],
10+
key5: function () {
11+
console.log("hello");
12+
},
13+
key: "new value", // 객체의 속성은 중복될 수 없다. 중복될 경우 마지막에 정의된 속성이 덮어쓴다.
14+
};
15+
16+
console.log(obj2.key); // 점 표기법을 이용한 속성 접근
17+
console.log(obj2["key"]); // 괄호 표기법을 이용한 속성 접근
18+
let propertyName = "key";
19+
console.log(obj2[propertyName]); // 변수 또는 표현식을 이용한 속성 접근을 할 때는 괄호 표기법을 사용해야 한다.
20+
21+
const person = {
22+
name: "seunan", // 함수가 아닌 property -> Member
23+
age: 24,
24+
say: function () {
25+
console.log(`hello, my name is ${this.name}`); // this는 객체 자신을 가리킨다.
26+
}, // 함수인 property -> Method
27+
};
28+
29+
person["gender"] = "man"; // const로 선언된 객체 자체를 변경하는 것은 불가능하지만 객체의 속성을 변경하는 것은 가능하다.
30+
person.location = "seoul"; // 객체의 속성을 동적으로 추가할 수 있다.
31+
32+
/* person = {
33+
name : "babo",
34+
age : 01,
35+
}; // const로 선언된 객체 자체를 변경하는 것은 불가능하다. */
36+
37+
console.log(person);
38+
39+
delete person.location; // 객체의 속성을 삭제할 수 있다.
40+
delete person["gender"]; // delete로 삭제한 property는 메모리 공간에서 완전히 삭제되지 않으므로 null로 초기화해주는 것이 좋다.
41+
person.name = null;
42+
43+
console.log(person);
44+
45+
function getPropertyValue(key) {
46+
console.log(person[key]);
47+
}
48+
getPropertyValue("location");
49+
getPropertyValue("gender");
50+
51+
person.say();
52+
53+
console.log(`name : ${"name" in person}`); // in 연산자를 이용해 객체에 특정 속성이 있는지 확인할 수 있다.
54+
console.log(`age : ${"age" in person}`);
55+
console.log(`location : ${"location" in person}`);
56+
57+
console.log(`name : ${person.hasOwnProperty("name")}`); // hasOwnProperty 메소드를 이용해 객체 자신의 속성인지 확인할 수 있다.

JavaScript/4-Array.js

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
let firstArr = new Array(1, 2, 3, 4); // 배열 생성자 함수를 이용한 배열 생성
2+
let randArr = [1, "2", true, null, undefined, {}, [], function () {}]; // 배열 리터럴을 이용한 배열 생성
3+
4+
firstArr.push(5); // 배열의 끝에 요소를 추가한다.
5+
6+
console.log(firstArr.length); // 배열의 길이를 반환한다.
7+
8+
console.log(randArr);
9+
10+
const person = {
11+
name: "seunan", // 함수가 아닌 property -> Member
12+
age: 24,
13+
say: function () {
14+
console.log(`hello, my name is ${this.name}`); // this는 객체 자신을 가리킨다.
15+
}, // 함수인 property -> Method
16+
};
17+
18+
const personKeys = Object.keys(person); // 객체의 속성들을 배열로 반환한다.
19+
const personValues = Object.values(person); // 객체의 속성들의 값을 배열로 반환한다.
20+
21+
for (let i = 0; i < personKeys.length; i++) {
22+
console.log(`${personKeys[i]} : ${personValues[i]}`);
23+
}
24+
25+
const numArr = [1, 2, 3, 4, 5];
26+
27+
// const newArr = [];
28+
// arr.forEach((elm) => newArr.push(elm * 2)); // 배열의 요소들을 순회하며 콜백함수를 실행한다.
29+
const newArr = numArr.map((elm) => elm * 2); // 배열의 요소들을 순회하며 콜백함수를 실행한 결과를 새로운 배열에 담아 반환한다.
30+
31+
console.log(numArr.includes(3)); // 배열에 특정 요소가 있는지 확인한다.
32+
console.log(numArr.indexOf("3")); // 배열에 특정 요소가 있는지 확인하고 있을 경우 해당 요소의 인덱스를, 없으면 -1을 반환한다.
33+
34+
const arr = [
35+
{ num: 1, color: "red" },
36+
{ num: 2, color: "blue" },
37+
{ num: 3, color: "green" },
38+
{ num: 4, color: "yellow" },
39+
];
40+
41+
console.log(
42+
arr.findIndex((elm) => {
43+
return elm.color === "red";
44+
})
45+
);
46+
47+
const idx = arr.findIndex((elm) => elm.color === "red"); // 배열의 첫 요소부터 순회하며 콜백함수를 실행한 결과가 true가 되는 요소의 인덱스를 반환한다.
48+
console.log(arr[idx].color);
49+
50+
const element = arr.find((elm) => elm.color === "red"); // 배열의 첫 요소부터 순회하며 콜백함수를 실행한 결과가 true가 되는 요소를 반환한다.
51+
console.log(element.color);
52+
53+
const filteredArr = arr.filter((elm) => elm.color === "red"); // 배열의 첫 요소부터 순회하며 콜백함수를 실행한 결과가 true가 되는 요소들을 모아 새로운 배열로 반환한다.
54+
console.log(filteredArr);
55+
56+
const arr1 = arr.slice(0, 2); // 배열의 특정 구간을 잘라 새로운 배열로 반환한다.
57+
const arr2 = arr.slice(2, 4);
58+
59+
console.log(arr1.concat(arr2)); // 배열을 합쳐 새로운 배열로 반환한다.
60+
61+
let numbers = [0, 1, 3, 2, 10, 30, 20];
62+
console.log(numbers.sort()); // sort() 메서드는 기본적으로 유니코드 순서로 정렬한다.
63+
64+
const compare = (a, b) => {
65+
if (a > b) return 1; // 콜백함수의 반환값이 0보다 크면 a를 b보다 뒤로 정렬한다.
66+
if (a === b) return 0; // 콜백함수의 반환값이 0이면 a와 b의 순서를 바꾸지 않는다.
67+
if (a < b) return -1; // 콜백함수의 반환값이 0보다 작으면 a를 b보다 앞으로 정렬한다.
68+
};
69+
70+
numbers.sort(compare); // 숫자를 오름차순으로 정렬하려면 콜백함수를 이용해야 한다.
71+
console.log(numbers);
72+
73+
console.log(numbers.sort((a, b) => a - b));
74+
75+
const cArr = ["안승원", "님", "안녕하세요", "반갑습니다"];
76+
77+
console.log(cArr.join(" ")); // 배열의 요소들을 구분자(default는 ,)를 이용해 하나의 문자열로 합친다.
78+
79+
/*
80+
function transformToObjects(numberArray) {
81+
// TODO: Add your logic
82+
// should return an array of objects
83+
return numberArray.map((item) => {
84+
return {var : item};
85+
})
86+
// return numberArray.map((item) => ({var : item}))
87+
}
88+
89+
const objArr = transformToObjects([1, 2, 3, 4]); // [{var: 1}, {var: 2}, {var: 3}, {var: 4}];
90+
console.log(objArr);
91+
92+
// Destructuring
93+
const [firstName, lastName] = ["Seungwon", "An"];
94+
95+
console.log(`firstName : ${firstName}, lastName : ${lastName}`);
96+
97+
const {name: userName, age} = {name : "seunan", age : 24};
98+
99+
console.log(`userName : ${userName}, age : ${age}`);
100+
101+
// Spread Operator
102+
const arr1 = [1, 2, 3];
103+
const arr2 = [4, 5, 6];
104+
const arr3 = [...arr1, ...arr2];
105+
console.log(arr3);
106+
107+
const arr = [1, 2, 3, 4, 5];
108+
109+
console.log("-----------------map-----------------");
110+
111+
const newArr = arr.map((item) => item * 2);
112+
console.log(newArr);
113+
114+
console.log("------------------find-----------------");
115+
116+
const found = arr.find((item) => item > 3);
117+
console.log(found);
118+
119+
console.log("-----------------findidx----------------");
120+
121+
const foundIdx = arr.findIndex((item) => item > 3);
122+
console.log(foundIdx);
123+
124+
console.log("-----------------filter-----------------");
125+
126+
const filtered = arr.filter((item) => item > 3);
127+
console.log(filtered);
128+
129+
console.log("-----------------slice-----------------");
130+
131+
// 원래 배열은 변하지 않음
132+
const sliced = arr.slice(1, 3);
133+
console.log(sliced);
134+
console.log(arr);
135+
136+
console.log("-----------------splice-----------------");
137+
138+
// 원래 배열이 변함
139+
const spliced = arr.splice(1, 2);
140+
console.log(spliced);
141+
console.log(arr);
142+
143+
const hobbies = ['reading', 'coding', 'listening to music', 'watching movies', 'playing games'];
144+
145+
for (const hobby of hobbies) {
146+
console.log(hobby);
147+
}
148+
*/

JavaScript/5-Class.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// 객체의 속성과 메서드를 정의한 클래스
2+
class Human {
3+
constructor(name, age) {
4+
this.name = name;
5+
this.age = age;
6+
}
7+
8+
say() {
9+
console.log(
10+
`hello, my name is ${this.name} and I'm ${this.age} years old.`
11+
);
12+
}
13+
}
14+
15+
// 클래스를 사용하기 위해서 인스턴스를 생성해야 한다.
16+
const seunan = new Human("seunan", 24);
17+
seunan.say();

JavaScript/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# JavaScript
2+
3+
## What is JavaScript?
4+
5+
- 가벼운 인터프리터 혹은 just-in-time 컴파일 프로그래밍 언어
6+
- 웹 페이지를 위한 스크립트 언어로 잘 알려져 있지만, Node.js 같은 비 브라우저 환경에서도 사용
7+
- JavaScript는 프로토타입 기반, 다중 패러다임, 단일 스레드, 동적 언어로, 객체지향형, 명령형, 선언형(함수형 프로그래밍 등) 스타일을 지원
8+
9+
## Variable
10+
11+
`var`, `let`, `const` 키워드를 사용하여 변수를 선언할 수 있다.
12+
13+
```javascript
14+
var v = 1;
15+
var v = 2; // var 키워드는 중복 선언, 재할당 모두 가능
16+
17+
let l = 1;
18+
l = 2;
19+
// let l = 2; // let 키워드는 중복 선언이 불가능, 재할당은 가능
20+
21+
const c = 1;
22+
// c = 2;
23+
// const c = 2; // const 키워드는 중복 선언, 재할당 모두 불가능
24+
```
25+
26+
## Function
27+
28+
```javascript
29+
function add(a, b) {
30+
return a + b;
31+
}
32+
33+
const add = (a, b) => a + b;
34+
```
35+
36+
## Keyword
37+
38+
- ES6
39+
- Sync/Async
40+
- Promise
41+
- Module
42+
- Class
43+
- Arrow Function
44+
- Destructuring
45+
- Spread/Rest
46+
- Template Literals
47+
48+
## Learning Resources
49+
50+
- [MDN](https://developer.mozilla.org/ko/docs/Web/JavaScript)
51+
- [Modern JavaScript Tutorial](https://ko.javascript.info/)
52+
- [벨로퍼트와 함께하는 모던 자바스크립트](https://learnjs.vlpt.us/)
53+
- [Modern JavaScript Deep Dive](https://42seoul.dkyobobook.co.kr/content/contentView.ink?brcd=4801158392230&ctgrId=2113&sntnAuthCode=&cttsDvsnCode=001&selViewCnt=20&pageIndex=1&recordCount=20)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

JavaScript/es.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const sandwich = {
2+
bread: 'white',
3+
cheese: 'cheddar',
4+
veggies: 'lettuce'
5+
}
6+
7+
let {bread: b, cheese: c, veggies: v} = sandwich;
8+
9+
console.log (b, c, v); // white cheddar lettuce
10+
11+
const [,fal] = [true, false];
12+
13+
console.log(fal); // true false
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)