📝
서은 STUDY_SCRIPT
  • JAVASCRIPT 기록
  • JAVASCRIPT 문법정리
    • 데이터 저장하기
    • 데이터 불러오기
    • 데이터 실행하기
    • 데이터 제어하기
    • 면접질문 정리
  • PHP를 이용한 사이트 작업
    • PHP와 MySQL
      • 댓글쓰기
      • 회원가입
      • 로그인
      • 게시판
        • 페이지네이션 & 게시글보기
        • 수정/삭제/목록/검색
  • 생활코딩 JavaScript
    • JavaScript 입문수업
      • Basic
        • 자바스크립트 기본 세팅
        • 데이터타입
        • 변수
        • 연산자
        • 조건문
        • 반복문
        • 함수
        • 배열
        • 객체
        • 모듈
        • 정규표현식
      • 함수지향
        • 유효범위
        • 값으로서 함수
        • 값으로서 콜백
        • 클로저
        • arguments
        • 함수의 호출
      • 객체지향
        • 생성자와 new
        • 전역객체
        • this
        • 상속
        • Prototype
        • 표준내장객체의 확장
        • Object
        • 데이터 타입
        • 복제 & 참조
    • JavaScript Basic
      • 자바스크립트란?
      • 데이터타입
      • 변수와 대입연산자
      • 제어할 태그 선택
      • 비교연산자와 불리언
      • 조건문 if
      • 리팩토링
      • 배열 [ ]
      • 반복문 while
      • 배열과 반복문
        • 배열과 반복문의 활용
      • 함수
        • 함수의 활용
      • 객체 { }
        • 객체와 반복문 for~in
        • 프로퍼티와 메소드
        • 객체의 활용
      • 파일로 쪼개서 정리정돈
      • 라이브러리 & 프레임워크
      • UI & API
    • Web Browser
      • JavaScript란?
      • BOM
        • 전역객체 window
        • 사용자와 커뮤니케이션
        • Location 객체
        • Navigator 객체
        • 창 제어
      • DOM
        • 제어 대상 찾기
        • jQuery
        • HTMLElement
        • Element 객체
          • 식별자 API
          • 조회 API
          • 속성 API
        • Node 객체
          • Node 관계 API
          • Node 종류 API
          • Node 변경 API
          • jQuery 노드 변경 API
          • 문자열로 노드 제어
        • HTMLCollection
      • 이벤트
        • 이벤트 등록
        • 이벤트 전파(버블링과 캡처링)
        • 이벤트 기본 동작 취소
        • 이벤트 타입
      • 네트워크 통신
        • Ajax
        • JSON
  • NOMAD JAVASCRIPT
    • VanillaJS
      • Why JS?
      • ES5, ES6
      • Basic
        • Alert & Console
        • Variable
        • Data Types
        • Array & Object
      • Function
      • DOM
        • Event & Event handler
        • Conditional
        • Function Practice
      • Momentum App
        • Making a JS Clock
        • Saving the User Name
        • To-Do List
        • Image Background
        • Getting Weather
  • DREAM CODING
    • 자바스크립트 기초 강의 (ES5+)
      • JavaScript 역사
      • async & defer / Strict Mode
      • Variable / Hoisting / Data Type
      • Operator / if / Loop
      • Function
        • 함수의 선언
        • 함수의 표현
      • Class
      • Object
      • Array
      • Array API
      • JSON
      • Callback
      • Promise
      • Async & Await
  • WEB BOS
    • #JavaScript30
Powered by GitBook
On this page
  • 변수 : 데이터 저장 : 데이터 변경 : 데이터 추가
  • 01. 변수 : 데이터 저장 (var)
  • 02. 변수 : 데이터 저장 + 변경 (let)
  • 03. 변수 : 데이터 저장 + 변경 + 추가 (let)
  • 상수 : 데이터 저장 : 데이터 변경X : 데이터 추가X
  • 17. 상수 (const)
  • 배열 : 데이터 저장 : 여러개
  • 04. 배열 : 여러개의 데이터 저장소 (new Array)
  • 05. 배열 : 04번에서 발전
  • 06. 배열 : new Array -> [];
  • 07&18. 배열 : 06번에서 발전
  • 객체 : 데이터 저장 : 여러개 : 키와 값
  • 08. 객체 : 배열 스타일 : 표현방법1
  • 09. 객체 : 배열 스타일 : 표현방법2
  • 10. 객체 : 표현방법3
  • 11. 객체 : 표현방법4
  • 12. 객체 : 표현방법5 : 배열 속에 객체
  • 13. 객체 : 표현방법6 : 객체 속에 배열
  • 14. 객체 : 표현방법7 : 객체 속에 변수
  • 15. 객체 : 표현방법8 : 객체 속에 함수

Was this helpful?

  1. JAVASCRIPT 문법정리

데이터 저장하기

변수, 상수, 배열, 객체

  • 변수 : 데이터 저장 : 데이터 변경 : 데이터 추가

  • 상수 : 데이터 저장 : 데이터 변경X : 데이터 추가X

  • 배열 : 데이터 저장 : 여러개

  • 객체 : 데이터 저장 : 여러개 : 키와 값

변수 : 데이터 저장 : 데이터 변경 : 데이터 추가

01. 변수 : 데이터 저장 (var)

{
    var x = 100;
    var y = 200;
    var z = "javascript";

    document.write(x); //100
    document.write(y); //200
    document.write(z); //javascript
}

02. 변수 : 데이터 저장 + 변경 (let)

{
    let x = 100;
    let y = 200;
    let z = "javascript";
    
    x = 300;
    y = 400;
    z = "jquery";
    
    document.write(x); //300
    document.write(y); //400
    document.write(z); //jquery
}

03. 변수 : 데이터 저장 + 변경 + 추가 (let)

{
    let x = 100;
    let y = 200;
    let z = "javascript";
    x += 300;       // x = x + 300;
    x += 300;       // x == x + 300;
    x += 300;       // x === x + 300 = 1000;
    y += 400;       // y == y + 400 = 600;
    z += "jquery";

    document.write(x); //1000
    document.write(y); //600
    document.write(z); //javascriptjquery
}

상수 : 데이터 저장 : 데이터 변경X : 데이터 추가X

17. 상수 (const)

{
    const x = 100, y = 200, z = "javascript"

    document.write(x); //100
    document.write(y); //200
    document.write(z); //javascript
}

배열 : 데이터 저장 : 여러개

04. 배열 : 여러개의 데이터 저장소 (new Array)

    const arr = new Array();
    arr[0] = 100;
    arr[1] = 200;
    arr[2] = "javascript";

    document.write(arr[0]); //100
    document.write(arr[1]); //200
    document.write(arr[2]); //javascript
}

const 상수 : 변하지 않는 데이터

05. 배열 : 04번에서 발전

{
    const arr = new Array(100, 200, "javascript");

    document.write(arr[0]); //100
    document.write(arr[1]); //200
    document.write(arr[2]); //javascript
}

06. 배열 : new Array -> [];

{
    const arr = [];
    arr[0] = 100;
    arr[1] = 200;
    arr[2] = "javascript";
    
    document.write(arr[0]); //100
    document.write(arr[1]); //200
    document.write(arr[2]); //javascript
}

const arr = []; *중요! 대괄호 안에 많은 데이터가 있을 수 있음을 의미

07&18. 배열 : 06번에서 발전

{
    const arr = [100, 200, "javascript"];

    document.write(arr[0]); //100
    document.write(arr[1]); //200
    document.write(arr[2]); //javascript
}

객체 : 데이터 저장 : 여러개 : 키와 값

내장객체

  • 숫자객체

  • 문자열 객체

  • 배열 객체

  • 수학 객체 (최대값/최소)

  • 브라우저 객체

  • 요소 객체

  • 이벤트 객체

08. 객체 : 배열 스타일 : 표현방법1

{
    const obj = new Object();

    obj[0] = 100;
    obj[1] = 200;
    obj[2] = "javascript";
    
    document.write(obj[0]); //100
    document.write(obj[1]); //200
    document.write(obj[2]); //javascript
}

09. 객체 : 배열 스타일 : 표현방법2

{
    const obj = new Object();

    obj.a = 100;
    obj.b = 200;
    obj.c = "javascript";

    document.write(obj.a); //100
    document.write(obj.b); //200
    document.write(obj.c); //javascript
}

10. 객체 : 표현방법3

{
    const obj = {};

    obj.a = 100;
    obj.b = 200;
    obj.c = "javascript";
    
    document.write(obj.a); //100
    document.write(obj.b); //200
    document.write(obj.c); //javascript
}

const obj = new Object(); → const obj = {};

11. 객체 : 표현방법4

{
    const obj = {
        a: 100,
        b: 200,
        c: "javascript"
    }
    
    document.write(obj.a); //100
    document.write(obj.b); //200
    document.write(obj.c); //javascript
}

12. 객체 : 표현방법5 : 배열 속에 객체

{
    const obj = [
        {a:100, b:200},
        {a:"javascript"}
    ]

    document.write(obj[0].a); //100
    document.write(obj[0].b); //200
    document.write(obj[1].a); //javascript
}

13. 객체 : 표현방법6 : 객체 속에 배열

{
    const obj = {
        a: 100,
        b: [200, 300],
        c: {x:400, y:500},
        d: "javascript"
    }

    document.write(obj.a);    //100
    document.write(obj.b[0]); //200
    document.write(obj.b[1]); //300
    document.write(obj.c.x);  //400
    document.write(obj.c.y);  //500
    document.write(obj.d);    //javascript
}

객체 안에 객체도 가능 ex) c: {x:400, y:500, z:{300}}

14. 객체 : 표현방법7 : 객체 속에 변수

{
    const a = 100;
    const b = 200;
    const c = "javascript";

    const obj = {a,b,c}

    document.write(obj.a); //100
    document.write(obj.b); //200
    document.write(obj.c); //javascript
}

15. 객체 : 표현방법8 : 객체 속에 함수

{
    const obj = {
        a: 100,
        b: [200, 300],
        c: "javascript",
        d: function(){
            document.write("javascript가 실행되었습니다.")
        },
        e: function(){
            document.write(obj.c + "가 행되었습니다.");
        },
        f: function(){
            document.write(this.c + "가 실행되었습니다."); //this 쓰는게 가장 좋은 방법
        }
        
        document.write(obj.a);      //100
        document.write(obj.b);      //200,300
        document.write(obj.b[0]);   //200
        document.write(obj.b[1]);   //300
        document.write(obj.c);      //javascript
        obj.d();                    //javascript가 샐행되었습니다.
        obj.e();                    //javascript가 샐행되었습니다.
        obj.f();                    //javascript가 샐행되었습니다.
    }
}
PreviousJAVASCRIPT 기록Next데이터 불러오기

Last updated 3 years ago

Was this helpful?