LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Saturday, January 27, 2018

JavaScriptで現在実行中の関数名を取得したい


arguments.callee.name でその関数名を取得できる



コード.gs
function get_function_name(){
  var name = arguments.callee.name;
  Logger.log(name);
}
意訳
この機能がやること
この機能の名前を取得して
ログに出す






補足


関数の中身を見たい

arguments.callee で現在実行中の関数の中身を取得できる




コード.gs
function get_function_code(){
  var code = arguments.callee;
  Logger.log(code);
}
意訳
この機能がやること
この機能の中身を取得して
ログに出す







参考

arguments.callee - JavaScript | MDN
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments/callee

Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...