eajni IT 초보사전 💦💦

[JavaScript] 자바스크립트 기초 (요약, 출력문)

2023-07-26

  • CSS = adj.
  • HTML = noun.
  • JS = verb.

JavaScript

Values

  • Literals : Fixed values
  • Variables : Variable values

    Operators

  • *
  • /
  • +
  • -
  • = : assignment

Expressions

  • a combination of values, variables, and operators

    Keywords

  • var : declares a variable
  • let : declares a block variable
  • const : declares a block constant
  • if
  • switch
  • for
  • return
  • try
  • Comments
    • // oneLine
    • /* multiLine */

this

호출 위치 지칭 객체
in an object method the “owner” of the object
alone the global object
in a funciton global object
in a function, in strict mode undefied
in an event the element that received the event

Chrome의 console은 간단한 REPL 프로그램!
Read-Evaluate-Print-Loop의 과정을 통해 빠르게 JS 소스 코드를 실행함

innerHTML

  • to access an HTML element
    document.getElementById("id").innerHTML = "changed";
    

document.write()

  • testing purpose only ```js <button type=”button” onclick=”document.write(“test”)”>Try it</button> //HTML 초기 load 이후 작동 시 기존 HTML 요소 전체 사라짐

```

window.alert()

  • window(global scope object) is optional

    console.log

  • debugging purpose
    • aleart() 경고창
    • prompt() 입력창에 input된 값 콘솔 출력
    • parseInt("string") str을 num으로 변환 출력
    • console.log() 요청 값 콘솔 출력

Comments

Content