LANG SELRCT

Google Apps Scriptのコードを書く場所  (新規作成: スプレッドシート | スクリプトエディタ

2020年2月7日金曜日

GASでアロー関数などが使えるようになった


Release Notes
https://developers.google.com/apps-script/releases#february_5_2020


V8 syntax examples に記載されているリストによると
  • let and const
  • Arrow functions
  • Classes
  • Destructuring assignments
  • Template literals
  • Default parameters
  • Multi-line strings
などが使えるらしい。


手順は簡単で

プロジェクトを開くとこのような表示が出る。(アカウントによってはまだ出ない)
「Enable」をクリックするだけ。



戻したい場合

Run メニューから戻すこともできる
 Run > Disable new Apps Script runtime powered by Chrome V8




既存のRhino runtimeとV8 runtimeの非互換性によって、移行後に既存のコードが失敗する可能性もあるらしい。(ほぼ大丈夫っぽいけど)

https://developers.google.com/apps-script/guides/v8-runtime/migration

失敗したら修正しよう。


参考

https://developers.google.com/apps-script/releases
February 5, 2020
Apps Script now supports the V8 runtime. This enables modern JavaScript features and syntax in Apps Script. You can migrate existing scripts to use V8 and its features.
V8 Runtime Overview
https://developers.google.com/apps-script/guides/v8-runtime

Migrating scripts to the V8 runtime
https://developers.google.com/apps-script/guides/v8-runtime/migration

V8 syntax examples
https://developers.google.com/apps-script/guides/v8-runtime#v8_syntax_examples

Modern JavaScript features
https://developers.google.com/apps-script/guides/services/#modern_javascript_features
The V8 runtime supports modern ECMAScript syntax and features. The Rhino runtime is based on the older JavaScript 1.6 standard, plus a few features from 1.7 and 1.8. You can freely choose which runtime to use with your script, but the V8 runtime is strongly recommended.

最新の投稿

JIRA APIで選択リスト(複数選択)を課題作成時に選択してPOSTしたい

JIRA APIを利用して選択リスト(複数選択)フィールドに値を入れたくて書いたコードです。 コード.gsのこの部分で複数選択の値を選択できました。 customfield_10043 は手元のJIRAでの選択リスト(複数選択)のフィールドIDなので、各自の環境によって異なります...