본문 바로가기

Dev

(40)
Javascript JS 형변환 String() console.log( String(3), String(true), String(null), String(undefined) ) Number() console.log(Number("1234"), Number(true), Number(false), Number("1234asdf456")); Boolean() true console.log(Boolean(1), Boolean(123), Boolean("Javascript")); false console.log(Boolean(0), Boolean(""), Boolean(null), Boolean(undefined), Boolean(NaN));
Javascript JS alert, prompt, confirm prompt 1. 디폴트값 없이 const name = prompt("이름을 입력하세요."); 2. 디폴트값 있이 const name = prompt("날짜 입력", "2010-10"); alert const name = "Mike"; alert("환영합니다. " + name + "님"); alert(`환영합니다. ${name}님`); confirm const isAdult = confirm("당신은 성인 입니까?"); console.log(isAdult); 특징 1. 스크립트 일시 정지 2. 스타일링 불가능
Javascript JS 자료형 String 문자 const name = "Mike"; // 3가지 방식으로 선언 가능 const name1 = "Mike"; const name2 = 'Mike'; const name3 = `Mike`; // 작은 따옴표를 사용할때 큰따옴표로 감쌈 const message = "I'm a boy."; // 작은 따옴표만 사용하고 싶을때 \ 이스케이프 처리 const message2 = 'I\'m a boy'; // 변수를 넣고 싶을때 const message3 = `My name is ${name}`; const message4 = `나는 ${30+1}살 입니다.`; console.log(message3); console.log(message4); Integer 숫자 const age = 30; // ..
Javascript JS 변수 var 1. 변수명 중복이 가능 2. 값 변경 가능 3. 변수명이 중복일 경우 마지막 값으로 덮어짐 let 1. 변수명 중복이 불가능 2. 값 변경 가능 const 1. 변수명 중복 불가능 2. 값 변경 불가능
Node.js 설치 삭제(완전 삭제) 1. 제어판에서 Node.js 삭제 2. 해당 경로의 디렉토리 삭제 C:\Program Files (x86)\Nodejs C:\Program Files\Nodejs C:\Users\User\AppData\Roaming\npm C:\Users\User\AppData\Roaming\npm-cache 삭제 후 확인 버전확인 node -v npm -v
Node.js 설치 Node.js 최신버전 Node.js 이전버전 설치 후 확인 버전확인 node -v npm -v
자바 JAVA 람다식 기본 골자 public class lamda01 { public static void main(String[] args) { Sample01Function f = () -> { System.out.println("샘플01테스트 출력1"); System.out.println("샘플01테스트 출력2"); }; f.test(); Sample02Function f2 = (a) -> a; System.out.println(f2.test("샘플02테스트 출력1")); Sample02Function f3 = a -> { // 괄호를 붙이면 반환값을 줘야함 return a; }; System.out.println(f3.test("샘플02테스트 출력2")); } } @FunctionalInterface interface..
타입스크립트 Typescript 제네릭 Typescript // Generic function getSize(arr: T[]): number { return arr.length; } const arr1 = [1, 2, 3]; getSize(arr1); const arr2 = ["1", "2", "3"]; getSize(arr2); interface Mobile { name: string; price: number; option: T; } const m1: Mobile = { name: "s21", price: 1000, option: { color: "red", coupon: false, } } const m2: Mobile = { name: "s20", price: 900, option: "good" } interface User { nam..
타입스크립트 Typescript 클래스 Typescript // 접근 제한자(Access modifier) - public, private, protected /* public - 자식 클래스, 클래스 인스턴스 모두 접근 가능 protected - 자식 클래스에서 접근 가능 private - 해당 클래스 내부에서만 접근 가능 readonly - 읽기만 가능 수정 불가 수정하려면 constructor를 통해 변경해야함 static - 접근하려면 class. 을 사용해야함 */ class Car { color: string; // 접근 제한자를 선언하지 않으면 기본 public //private color: string // 클래스 내부에서만 사용가능 같은 표현 #color: string static wheels: number = 4; const..
타입스크립트 Typescript 함수 Typescript // 함수 function hello(name:string, age?:number): string { if (age !== undefined) { return `Hello, ${name}. You are ${age}.`; } else { return `Hello, ${name}.`; } } console.log(hello("Same", 30)); console.log(hello("Same")); //let test:number = hello("Same", 30); 에러발생 타입 불일치 let test2:string = hello("Same", 30); // 오버로드 interface User { name: string; age: number; } function join(name: s..