보관함

javascript with 구문

AI 윤 선생 2020. 8. 19. 06:20
반응형

with구문은 다음과 같이 객체의 이름과 점(dot) 없이 기술 할 수 있습니다.

Syntax

with (object) { properties used without the object name and dot }

 

일반적으로 사용 할 떄

x = Math.cos(1 * Math.PI) + Math.sin(Math.LN5)
y = Math.tan(2 * Math.E)

with 구문

with (Math){
  x = cos(1 * PI) + sin (LN5)
  y = tan(2 * E)
}


※ The ‘with’ keyword is used as a kind of shorthand for referencing an object's properties or methods.

The object specified as an argument to with becomes the default object for the duration of the block that follows. The properties and methods for the object can be used without naming the object.




반응형