Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
6
Help us understand the problem. What is going on with this article?
@kuinaein

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

More than 1 year has passed since last update.

公式ドキュメントによると 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);
}
6
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kuinaein
非IT系中小企業のシステム担当です。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
6
Help us understand the problem. What is going on with this article?