9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google Apps ScriptのObject、Array及びStringのメンバ一覧

Posted at

公式ドキュメントによると Google Apps Script のベースは JavaScript1.8 相当ということなのですが、「ブラウザにはあるあのメソッドってApps Scriptで使えたっけ?」とよく悩むのでメモ。

Object

Object - staticメンバ

  • create
  • defineProperties
  • defineProperty
  • freeze
  • getOwnPropertyDescriptor
  • getOwnPropertyNames
  • getPrototypeOf
  • isExtensible
  • isFrozen
  • isSealed
  • keys
  • preventExtensions
  • prototype
  • seal

Object - インスタンスメンバ

  • __defineGetter__
  • __defineSetter__
  • __lookupGetter__
  • __lookupSetter__
  • constructor
  • hasOwnProperty
  • isPrototypeOf
  • propertyIsEnumerable
  • toLocaleString
  • toSource
  • toString
  • valueOf

Array

Array - staticメンバ

  • concat
  • every
  • filter
  • forEach
  • indexOf
  • isArray
  • join
  • lastIndexOf
  • map
  • pop
  • prototype
  • push
  • reduce
  • reduceRight
  • reverse
  • shift
  • slice
  • some
  • sort
  • splice
  • unshift

Array - インスタンスメンバ

  • concat
  • constructor
  • every
  • filter
  • forEach
  • indexOf
  • join
  • lastIndexOf
  • length
  • map
  • pop
  • push
  • reduce
  • reduceRight
  • reverse
  • shift
  • slice
  • some
  • sort
  • splice
  • toLocaleString
  • toSource
  • toString
  • unshift

String

String - staticメンバ

  • charAt
  • charCodeAt
  • concat
  • equalsIgnoreCase
  • fromCharCode
  • indexOf
  • lastIndexOf
  • localeCompare
  • match
  • prototype
  • replace
  • search
  • slice
  • split
  • substr
  • substring
  • toLocaleLowerCase
  • toLowerCase
  • toUpperCase

String - インスタンスメンバ

  • anchor
  • big
  • blink
  • bold
  • charAt
  • charCodeAt
  • concat
  • constructor
  • equals
  • equalsIgnoreCase
  • fixed
  • fontcolor
  • fontsize
  • indexOf
  • italics
  • lastIndexOf
  • length
  • link
  • localeCompare
  • match
  • replace
  • search
  • slice
  • small
  • split
  • strike
  • sub
  • substr
  • substring
  • sup
  • toLocaleLowerCase
  • toLocaleUpperCase
  • toLowerCase
  • toSource
  • toString
  • toUpperCase
  • trim
  • valueOf

メンバ一覧の取得に使ったスクリプト

function reportBasicTypeMembers() {
  var objects = [
    {foo: 'bar'}, // Oject
    ['1'], // Array
    new String(''),
  ];
  var report = {};
  for (var i = 0; i < objects.length; ++i) {
    var instance = objects[i];
    var ctor = instance.constructor;
    var proto = Object.getPrototypeOf(instance);
    var reportEntry = {
      constructor: ctor.name,
      staticMembers: Object.getOwnPropertyNames(ctor)
        .filter(function(name) {
          return -1 == ['arguments', 'arity', 'name', 'length'].indexOf(name);
        })
        .sort(),
      instanceMembers: Object.getOwnPropertyNames(proto).sort(),
    };
    report[reportEntry.constructor] = reportEntry;
  }
  var json = JSON.stringify(report, null, 2);
  // Logger.log だと途中で切れる
  SpreadsheetApp.getActiveSpreadsheet()
    .getActiveCell()
    .setValue(json);
}
9
7
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
9
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?