Apps Script公式リファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2018年3月6日火曜日

配列の要素をつなげる joinを使う


配列の要素をつなげて文字列にするコードの例です


こういう配列から
var array = ["hello","hi","hey"];


こういう文字列を作ってみます

  • hello,hi,hey
  • hellohihey
  • hello&hi&hey




コード.gs
function array_join(){
  var array = ["hello","hi","hey"];
  var with_comma = array.join();
  var without_comma = array.join("");
  var with_space = array.join("&");
  Logger.log([with_comma, without_comma, with_space]);
}
意訳
この処理は以下を実行する
配列を用意する
カンマでつなげた文字列(つなげる文字を指定しないとカンマでつながる)
要素を区切らずにつなげた文字列(つなげる文字を空文字にする)
要素を&でつなげた文字列
それぞれの結果をログに出す




実行結果


Latest post

Google Apps Scriptの障害時はIssueTrackerを見てみる - Incidents for Apps Script are reported on Issue Tracker

IssueTracker > Apps Script issues https://issuetracker.google.com/savedsearches/566234 Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...