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

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
JavaScript
50
3장 타입, 값, 변수
b[0]
=
1; // b
가
참조하는
배열을
변경합니다
.
a[0] //
=
> 1:
바뀐
부분은
변수
a
를
통해서도
보입니다
.
a
===
b //
=
> true: a
와
b
는
같은
객체를
참조하므로
같은
값입니다
.
이 코드에서 볼 수 있듯 객체나 배열을 변수에 할당하는 것은 참조를 할당하는 겁
니다. 객체나 배열을 변수에 할당한다고 해서 객체의 사본이 새로 생기는 것은 아
닙니다. 객체나 배열의 사본을 만들기 위해서는 반드시 객체 프로퍼티나 배열 요소
를 직접 복사해야 합니다. 다음 예제는 5.4.3절에서 설명할
for
루프를 사용하는 방
법입니다.
let a
=
["a","b","c"]; //
복사할
배열
let b
=
[]; //
복사해
넣을
대상
for(let i
=
0; i < a.length; i++) { // a
의
각
인덱스에
대해
b[i]
=
a[i]; // a
의
요소를
b
에
복사합니다
.
}
let c
=
Array.from(b); // ES6
에서는
Array.from()
으로
배열을
복사할
수
있
습니다
.
마찬가지로, 별개의 객체나 배열을 비교할 때는 양쪽의 프로퍼티나 요소를 비교해
야 합니다. 다음 코드는 배열을 비교하는 함수입니다.
function equalArrays(a, b) {
if (a
===
b) return ...
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