Comments

A comment is text ignored by the Arcade compiler. Comments allow you to document expressions in-line using plain language. They can be critical to helping others understand complex expressions. They can also be used to provide attribution or links to outside documentation.

Arcade allows you to write single-line and multi-line comments.

Single-line comments

Single-line comments must be preceded by two forward slashes (e.g. //).

1
// This is a single-line comment
1
$feature.POPULATION / AreaGeodetic($feature, "square-miles"); // Calculates population density
1
2
3
// You can stack single-line comments
// if you don't want to use a multi-line comment
$feature.POPULATION / AreaGeodetic($feature, "square-miles");

Multi-line comments

Multi-line comments may be enclosed within /* */

1
2
3
4
5
6
7
8
9
/*
 * Calculates Simpson's Diversity Index.
 * Example usage:
 *
 * var di = simpsonsDiversityIndex([404, 210, 0, 98]);
 */
 function simpsonsDiversityIndex(values) {
   // define function block here
 }

The /* */ syntax may also be used to add multiple comments on a single line.

1
Attachments($feature, 0 /*minsize*/, 1000000 /*maxsize*/, true /*inc metadata*/)

Comments for disabling statements

Comments may be used to disable statements while debugging expressions, or to test multiple scenarios.

1
2
3
4
// I'm not sure which unit will be most appropriate
// $feature.POPULATION / AreaGeodetic($feature, "square-miles");
// $feature.POPULATION / AreaGeodetic($feature, "square-kilometers");
$feature.POPULATION / AreaGeodetic($feature, "square-meters");

In this workflow, comments are useful ways to document test values while writing an expression. Testing is quick when you disable/enable each set of test values line by line.

1
2
3
4
5
6
7
8
9
10
11
function diversityIndex(values){
  // calculation would go here. It is irrelevant for this example.
}

// var testValues = [0, 0, 0, 0];  // returns NaN --- fix this! Should be 0
// var testValues = [100, 0, 0, 0];  // returns 0
// var testValues = [100, 100, 100, 100];  // returns 75
// var testValues = [null, null, null];  // returns NaN --- Should be null
var testValues = [234, 775, 10, 1999];  // returns 49

diversityIndex(testValues);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close