Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
いくつかの必須引数を持ち、いくつかのオプション引数も受け入れることができるカスタム関数を作成したいと考えています。これに関するドキュメントは見つかりませんでした。誰か知っていますか?Javascriptに似ていますか?
カスタム関数には必須フィールドとオプション フィールドの概念はありませんが、次のようなロジックを使用してその動作をエミュレートできます。
function foo(arg1, opt_arg2) { if (arg1 == null) { throw 'arg1 required'; } return 'foo'; }
オプションのパラメータに接頭辞「opt_」を使用するのが慣例ですが、必須ではありません。