사이트 내 전체검색
with 명령 (with statement)
로빈아빠
https://cmd.kr/javascript/80 URL이 복사되었습니다.

본문

반복되는 명령의 default 를 미리 설정한다.

무법 :
  with (object){
      statements
  }
      object      반복 수행 할 object
      statements  일련의 명령문

설명 : with 대신에 긴 object names 혹은 this. keywords 을 사용 할 수도 있다.

예제: 반복되는  Math.object
  radius = 5.4
  area = Math.PI * (radius*radius)
  cosinePI = Math.cos(Math.PI/2)
  sinePIdiv2 = Math.sin(Math.PI/2)

대신에
  radius = 5.4
  with (Math) {
      area = PI * (radius*radius)
      cosinePI = cos(PI/2)
      sinePIdiv2 = sin(PI/2)}

출처 : http://qdata.co.kr/bo/bbs/board.php?bo_table=jt&wr_id=12

댓글목록

등록된 댓글이 없습니다.

831 (10/17P)

Search

Copyright © Cmd 명령어 3.145.191.187