목록전체 글 (111)
Script
JSON-JavaScript Object Notation 자바스크립트에서 데이터를 저장하는 방식 1.Object를 Json으로 변환 stringify //stringify(obj) let json = JSON.stringify(true); console.log(json);//true json = JSON.stringify(['apple','banana']); console.log(json);//["apple","banana"] const rabbit = { name: 'tori', color: 'white', size: null, birthDate: new Date(), jump: () => { console.log(`${this.name}can jump!`); } }; json = JSON.string..
1.join 배열안에 있는 것들을 하나의 문자열로 만든다 { const fruits = ['apple','banana','orange']; const result = fruits.join();//()안에는 사이사이에 들어갈 것을 입력 //ex)fruits.join(|)-apple | banana | orange console.log(result);//apple,banana,orange } 2.split 하나의 문자열을 배열로 만든다 { const fruits ='🍎,🥝,🍌,🍒'; const result =fruits.split(',');//()안에는 무엇을 기준으로 쪼갤것인지를 입력 //fruits.split(',',2)- (2) ['🍎', '🥝'] console.log(result);//['🍎', '🥝..
1.선언 const arr1 = new Array();//방법 1 const arr2 = [1,2];// 방법2 2.Index 위치 const fruits = ['🍎','🍌'] console.log(fruits);//(2) ['🍎', '🍌'] console.log(fruits.length); //2 console.log(fruits[0]);//🍎 console.log(fruits[1]);//🍌 console.log(fruits[2]);//undefined console.log(fruits[fruits.length-1]);//🍌(배열의 마지막 데이터) 3.배열에서의 loop print all fruits힐때 a.for for (let i = 0; i < fruits.length; i++) { console..
object Js의 데이터 타입 중 하나이다 함수나 데이터와 연관된 것들의 모음 Js의 거의 모든 객체는 Object의 인스턴스이다 object = { key: value}; 1.literals and propertries 1-1.객체 리터럴, 객체 생성자 const obj1 = {}; //'객체 리터럴' syntax const obj2 = new Object(); //'객체 생성자' syntax //객체 리터럴 function print(person) { console.log(person.name); console.log(person.age); } //객체 생성자 const ellie = {name:'ellie',age:4}; print(ellie); 1-2.자바스크립트는 dynamically type..
Class: 클래스는 붕어빵을 굽는 틀(템플릿) class에서는 이 틀에는 ~~이 들어갈수 있다라는 틀의 모양만 잡음 Object: class안에 데이터를 넣어 만들어 진것이 object(객체) class는 틀만 잡은 것이기에 메모리에 저장되지 않으나 object는 직접적인 결과물이므로 메모리에 저장됨 1.Class 선언 생성자,필드,메소드로 구성 class Person { constructor(name,age){ //생성자 this.name=name;//필드 this.age=age; } //메소드 speak(){ console.log(`${this.name}:hello!`); } } 2.object 생성 틀안에 반죽넣는 과정 변수명=new class명(); const A= new Person('A',2..
함수 프로그램의 기본 빌딩 블록 subprogram이라고도 불리며 여러번 재사용이 가능하다 작업을 수행하거나 값을 계산하는데 쓰인다. 1.함수 선언 & 함수 호출 함수 선언 function name(parameter1,parameter2) {body... return;} 하나의 함수는 한가지의 일만 하도록 만들어야 한다 naming방식은 doSomething,command,verb형태로 해야한다 ex)createCardAndPoint ->가독성을 위해 createCard,createPoint로 나눠줄 필요가 있음 함수는 js에서 object로 취급. function printHello() { console.log('Hello'); } printHello();//Hello만 계속 출력 function lo..