Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1주차] 기본 과제 제출 #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions datatypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const sym1 = Symbol();
const sym2 = Symbol();
const sym3 = Symbol('foo');
const sym4 = Symbol('foo');

console.log(sym1 === sym1);

console.log(sym1 === sym2);
console.log(sym3 === sym4);

const user = {
email : "[email protected]",
name : "임채영",
favorite : ["초밥", "케이크"],
introduce : function() {
console.log(`${this.name}입니다. ${this.favorite} 좋아`);
},
getFavoriteFoods : function() {
this.favorite.forEach((food) => {
console.log(`${food} 맛있어`);
});
},
};

const arr1 = ["Hi", 10, true];
const arr2 = Array(1, null, "우와!", false, { sopt: "Server" });

arr1.map((item) => console.log("item1 :", item));
arr2.map((item) => console.log("item2 :", item));

const add = (a, b) => a + b;
const hello = name => console.log(`${name}, hello!`)
const info = (name, age) => ({name, age})
10 changes: 10 additions & 0 deletions eventdriven.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const sayHello = () => console.log("Hello");

const timer = () => {
return setTimeout(() => {
console.log("End !");
}, 3000);
};

sayHello();
timer();
21 changes: 21 additions & 0 deletions scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if (true) {
var x = "var";
}
console.log("x: ", x);

if (true) {
let y = "let";
}
console.log("y: ", y);

//* var가 function scope 를 벗어났을 때!
function func() {
if (true) {
var test = "var";
console.log("test: ", test);
}
console.log("test: ", test);
}

func();
console.log("test: ", test);
88 changes: 88 additions & 0 deletions typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const isLiked: boolean = true;
console.log(`${typeof isLiked}, ${isLiked}`)

const str: string = 'hellooo!!'
console.log(`${typeof str}, ${str}`)

let num: number = 31
console.log(`${typeof num}, ${num}`)

//const sum: number = 'sum number'

let numbers : number[] = [1, 2, 3];

const strings: Array<String> = ['hi', 'hello'];

const objArray1: Object[] = [
{item1: 'oh'},
{item2: 'wow'}
]

const objArray2: object[] = [
{item1: 'oh'},
{item2: 'wow'}
]

const foo1 = (something: object) : void => {
console.log(something)
}

const foo2 = (something: Object) : void => {
console.log(something)
}

foo1('boom')
foo2('boom')

const fun = (name: string): void => console.log(`hello, ${name}!`)

const sum1 = (a: number, b: number): number => a + b;

const sum2 = (a: number, b: number): number =>{
return a+b;
}

const a: null = null;

let oops: null = 2;

let b: undefined = undefined;

let c: undefined = null;

let str1: any = "임채영";
let str1Length: number = (<string>str1).length;
console.log(`${typeof str1Length}, ${str1Length}`);

let str2: any = "차윤주";
let str2Length: number = (str2 as string).length;
console.log(`${typeof str2Length}, ${str2Length}`);

const hmm: any={
name: "임채영",
age: 21,
isSOPT: true,
};

interface SOPT{
name: string;
age: number;
isSOPT: boolean;
}

const info : SOPT = {
name: "임채영",
age: 21,
isSOPT: true,
};

interface SOPT1{
name: string;
age: number;
isSOPT?: boolean;
}

const info: SOPT1 = {
name: "임채영",
age: 21,
}
16 changes: 16 additions & 0 deletions variables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var myName = "임채영";
console.log(`${myName} is wrong name !`);

var myName = "임채영";
console.log(`My name is ${myName}`);

let part = "Server";
let part = "Serverrrrr";
console.log(`Let's go ${part}`);

const school = "SOPT";
const school = "STOP";
console.log(`school ${part}`);

//let과 const 지향!!
//var let은 재할당 가능, const는 불가능