Skip to Content
자바스크립트 완벽 가이드
book

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
the De󼴩nitive Guide
141
5.6 기타 문
5.6
󺋿󼖏󽴔󻀇
이 절에서는
with
,
debugger
,
"use strict"
문을 설명합니다.
5.6.1

with
문은 지정된 객체의 프로퍼티가 해당 블록의 스코프 안에 있는 변수인 것처럼
코드 블록을 실행합니다. 문법은 다음과 같습니다.
with (object)
statement
이 문은
object
(객체)의 프로퍼티를 사용해 임시 스코프를 만들고, 그 스코프 안에
서
statement
(문)을 실행합니다.
스트릭트 모드에서는
with
문을 금지합니다(5.6.3절). 스트릭트 모드가 아니더라
도 이 문은 폐기된 것으로 간주하고 사용하지 않아야 합니다.
with
를 사용하는 자
바스크립트 코드는 최적화하기 어려우며
with
문을 사용하지 않는 동등한 코드에
비해 상당히 느리게 동작합니다.
with
문을 사용하는 이유는 깊이 중첩된 객체 계층 구조에서 타이핑을 줄이기 위
해서입니다. 예를 들어 클라이언트 자바스크립트에서 HTML 폼의 요소에 접근하기
위해 다음과 같은 표현식을 써야 한다고 가정합시다.
document.forms[0].address.value
이런 표현식을 자주 써야 한다면 다음과 같이
with
문을 써서 폼 객체의 프로퍼티
를 변수처럼 취급할 수 있습니다.
with(document.forms[0]) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

개발자를 위한 필수 수학

개발자를 위한 필수 수학

토머스 닐드
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9788966263462