코락 CoRock
코딩하는 락스타
코락 CoRock
  • 분류 전체보기 (393)
    • frameworks (19)
      • spring (19)
      • spring-boot (0)
      • testing (0)
    • languages (94)
      • java (39)
      • kotlin (0)
      • python (42)
      • r (13)
    • libraries (0)
    • programming (239)
      • android (13)
      • c (17)
      • cpp (22)
      • database (18)
      • design-pattern (4)
      • data-structures (11)
      • git (8)
      • hadoop (6)
      • html-css (7)
      • issue (4)
      • javascript (26)
      • jsp (34)
      • os (29)
      • php (6)
      • preferences (19)
      • etc (15)
    • discography (37)
      • k-pop (18)
      • pop (19)
    • blog (3)

블로그 메뉴

  • Programming
  • Java
  • JavaScript
  • Discography
  • K-Pop Songs
  • Pop Songs
  • Blog
  • Guestbook

공지사항

인기 글

태그

  • linux
  • oracle
  • python
  • jsp
  • 파이썬
  • 자바스크립트
  • Spring
  • Android
  • javascript
  • CentOS
  • r
  • Java

최근 댓글

최근 글

티스토리

반응형
hELLO · Designed By 정상우.
코락 CoRock

코딩하는 락스타

[33-js-concepts] 7. 식(expression) vs 문(statement) | Expression vs Statement
programming/javascript

[33-js-concepts] 7. 식(expression) vs 문(statement) | Expression vs Statement

2019. 12. 23. 19:46
반응형

[ Expression] 

 : 하나의 값을 결과로 가지는 javascript code snippet

  1. primary expression

 this, indenitifier, literal

  • this : evaluates to this value of the execution context - p36

  • literal - NullLiteral(null), BooleanLiteral(false, true), NumbericLiteral, StringLiteral

      2. new expression

           ex) new newExpression

       - 1. evaluate newexpression

       - 2. call getValue(Result(1))

       - 3. if type(result2) is not object, generater a runtime errror

       - 4. if result2 does not emplement the internal construct method, generate a reuntime error.

       - 5. call the construct method on result2, providing no arguments

       - 6.if type(result5) is not object, generate a runtime error

       - 7.return result 5;

     3. function expression - function call

     4. unary expression (연산자 식)

              :  연산자가 존재하는 경우, 하나의 결과값을 도출

 

                                                                                                                                                                

 

[ Statement ]

     => 인터프리터에게 내리는 지시문

  • statement 가 파생된 이후에 값을 남기지 않음

  • 종류

: 메모리에서의 생성

ex) class, structure

: 흐름제어

  • 조건 분기와 반복처리

  ex) if, switch, for, while….

  1. variable statement 

ex) var [variableDeclarationLIst]

           variable initializer 

            ex) = [assignmentexpression]

      2.  empty statement

            ex) ;  (+) expression; - > expression satatement

      3.  if statement

           ex) if(expression) statement else statement

                 if(expression) statement

         -1. evaluate expression

         -2. call getValue(result(1))

         -3. call toboolean(result(2))

         -4. if result(3) is false, return ‘normal completion”

         -5. evaluate statement.

         -6. return result(5)

      4.  iteration stataement

           while(expression) statement, for(Expression;expression;expression) statement

           for(lefthandsideexpressoin in expression) statement

           for (Var indeifiier initializer in expression) statement

      5.  with statement 

          with(object) statement;  - 속성들을 바로 접근 가능함

  •  해당 객체를 scope chain에 새로 넣음() -> 추가적인 자원 소모

            

     6. function definition

         function indetifier (formalParameterList) block

          - 1.create a new function obejct with parameter specified by the formalparameterlist, the block as the body , and identifier as its name; 

         -2. put his new function object as the new value of the property named identifier in the global object or the activation object, as appropriate - p56 

 

      7. return statement;

 

     ++

         //function expression

           javascirpt에서 function은 first-class-object라고 하는데, 이는 

              변수를 저장, 함수의 파라미터로 전달가능, 함수의 반환값으로 사용가능, 자료구조에 저장 가능한 객체를 언급하는 말이다.

         : function literal로, 특정 변수에 할당되거나 즉시 실행가능한 코드 블럭으로서 존재하는 함수를 의미

           => function declaration 을  실행코드로 해석하기 위해서는 ()를 이용 -
                > 자기 호출함수 (self invoking function) : 해석과 동시에 실행하는 함수

        : named function expression

          => 특징 : 해당 함수의 이름을 함수밖에서 사용x

                 

                      //=> 호이스팅이 발생하지 않도록, 사용

 

반응형
저작자표시 비영리 변경금지 (새창열림)
    'programming/javascript' 카테고리의 다른 글
    • [33-js-concepts] 9. 메시지 큐와 이벤트 루프 (Message Queue and Event Loop)
    • [33-js-concepts] 8. IIFE, Modules, Namespaces
    • [33-js-concepts] 6. 함수 범위, 블록 범위, 렉시컬 범위 (Function Scope, Block Scope and Lexical Scope)
    • [33-js-concepts] 5. == vs. === vs. typeof
    코락 CoRock
    코락 CoRock
    A COder dreaming of being a ROCKstar

    티스토리툴바