반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- PostgreSQL
- Tkinter
- Google Spreadsheet
- Redshift
- Google Excel
- hive
- c#
- Mac
- django
- array
- matplotlib
- dataframe
- Apache
- PySpark
- SQL
- Java
- google apps script
- Python
- list
- numpy
- string
- math
- Excel
- Kotlin
- 파이썬
- gas
- PANDAS
- GIT
- Github
Archives
- Today
- Total
달나라 노트
Google Apps Script : 배열 Array (list) 본문
728x90
반응형
여러 값을 하나로 묶어서 다룰 수 있게 해주는 배열(array)을 알아봅시다.
Python의 list와 매우 흡사합니다.
function myFunction() {
var arr_test = [1, 2, 3, 4, 5];
console.log(arr_test[1]);
console.log(arr_test[2]);
}
-- Result
2
3
위처럼 배열은 대괄호[]를 이용해서 선언하며 indexing이 가능합니다.
index는 배열의 가장 첫 번째 요소가 0이며 그 후 1씩 증가합니다.
function myFunction() {
var arr_test = [1, 2, 3, 4, 5];
console.log(arr_test[1]);
arr_test[1] = 10;
console.log(arr_test[1]);
}
-- Result
2
10
위처럼 indexing을 이용해서 특정 위치의 값을 변경할 수 있습니다.
위 코드는 index = 1 위치의 값인 2를 10으로 바꾸는 코드입니다.
function myFunction() {
var arr_test = [[1, 2], [3, 4, 5], [10, 20, 30, 40, 50]];
console.log(arr_test[1]);
console.log(arr_test[2][3]);
}
-- Result
[ 3, 4, 5 ]
40
위처럼 array 속에 array를 담아 다차원 array도 가능합니다.
위 코드는 array 속 array가 있는 형태로 2차원 array이며 그 이상의 차원을 가진 array도 가능합니다.
728x90
반응형
'Google Apps Script' 카테고리의 다른 글
Google Apps Script : Date (오늘 날짜, today, 현재 날짜, 현재 시간, GMT, UTC) (0) | 2022.11.21 |
---|---|
Google Apps Script : 객체, 객체 리터럴 (dictionary) (2) | 2022.11.16 |
Google Apps Script : ` (Backtick, 여러 줄 문자 표시하기. format. placeholder) (0) | 2022.11.16 |
Google Apps Script : 디버그 (Debug) (0) | 2022.11.16 |
Google Apps Script : 프로젝트의 종류 (Standalone script, Container bound script) (0) | 2022.11.16 |
Comments