3-10.Array Destructuring
2023. 3. 30. 09:27ㆍJavascript/자바스크립트 제대로 배워볼래?
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
// Array Destructuring
function getScores() {
return [70, 80, 90];
}
var scores = getScores();
console.log(scores);
console.log(scores[0]);
var [x,y,z] = getScores();
console.log(y);
// 두개만 해도 상관 없다
var [x,y] = getScores();
console.log(y);
// 위도(latitude), 경도(longitude)
function getLocation() {
return [123.12, 23.023];
}
var [latitude, longitude] = getLocation();
console.log(latitude);
</script>
</body>
</html>
'Javascript > 자바스크립트 제대로 배워볼래?' 카테고리의 다른 글
3-12.Async_Await (0) | 2023.03.30 |
---|---|
3-11.Promise (0) | 2023.03.30 |
3-09.Object Destructuring (0) | 2023.03.30 |
3-08.Spread Operator (0) | 2023.03.30 |
3-07.Object Literal Syntax Extension !!! 0_0 (0) | 2023.03.30 |