LoginSignup
24
20

More than 5 years have passed since last update.

Google Apps Scriptで使えるJSのバージョンについて調査

Last updated at Posted at 2019-02-27

はじめに

未来になると拡張されてると思うので 2019/02/27 時点での話です。

対応しているバージョン

  • https://developers.google.com/apps-script/guides/services/#basic_javascript_features
  • 公式にはJavaScript 1.6をベースにしていて1.7と1.8のfeatureも少し入ってるよ、というアナウンス
    • 何が入ってて何が入ってないは書いていないので読者の想像に任せられている... :poop:
  • :arrow_up: の記事から各バージョンへのリンクはMDNに向けて貼られているのでMDNでのスペックで調べてます

1.6

feature 対応状況
E4X :o:
Arrayの拡張 :o:
Array および String の汎用化 :o:

1.7

feature 対応状況
ジェネレータ (yield) :x:
イテレータ :o:
配列内包 :o:
let :x:
分割代入 :o:

1.8

1.8.11.8.5のfeatureも含む

feature 対応状況
式クロージャ :x:
ジェネレータ式 :x:
Array.reduce :o:
Array.reduceLight :o:
Object.getPrototypeOf :o:
Using Native JSON :o:
Object.create :o:
Object.defineProperty :o:
Object.defineProperties] :o:
Object.getOwnPropertyDescriptor :o:
Object.keys :o:
Object.getOwnPropertyNames :o:
Object.preventExtensions :o:
Object.isExtensible :o:
Object.seal :o:
Object.isSealed :o:
Object.freeze :o:
Object.isFrozen :o:
Array.isArray :o:
Date.toJSON :o:
getter/setter :o:
strictモードのサポート :question:
Proxy :x:

まとめ

  • 意外と対応していたのでGASがんばってる
  • polyfillが使えないんでES7で入った仕様とかはGASだと現状は動きません :cry:
    • たとえば Array.prototype.includes
  • strictモードのサポートが :question: になっているのはちゃんとエラーになるケースならないケースがあったので部分的に対応してるようだったからです
24
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
20