--- title: "IMCScript built-in functions" slug: "imcscript-built-in-functions" description: "Use this reference to explore available IMCScript built-in constants and functions and how to use them effectively." updated: 2025-09-25T15:23:28Z published: 2025-09-25T15:23:28Z canonical: "docs.zilliant.com/imcscript-built-in-functions" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.zilliant.com/llms.txt > Use this file to discover all available pages before exploring further. # IMCScript built-in functions IMCScript offers a rich library of built-in constants and functions to help you define and execute custom logic with minimal code. The script engine supports mathematical operations, language constants, statistical calculations, expression-based queries, parsing utilities, and integration with external data such as GeoJSON and Google Maps. Use this reference to explore what’s available and how to use each function effectively. ## Math constants Use the following constants to improve script readability. ```javascript Math.PI     ;   // Outcome: 3.141592653589793 Math.E      ;   // Outcome: 2.718281828459045 ``` ## Language constants Language constants help you retrieve standardized language-country codes based on international conventions. Common examples include: ```javascript Lang.GERMAN;              // Outcome: "de" Lang.ENGLISH;             // Outcome: "en" Lang.CHINESE;             // Outcome: "zh" Lang.TRADITIONAL_CHINESE; // Outcome: "zh_TW" ``` ## Standard functions ### Summation (sum) Adds all provided values. Accepts comma-separated or array inputs. ```javascript Math.sum(10, 20, 30)    ;   // Outcome: 60 Math.sum([1, 2, 3, 4])  ;   // Outcome: 10 ``` ### Multiplication (mul) Multiplies all values. ```javascript Math.mul(1, 2, 3)         ;   // Outcome: 6 Math.mul([2, 3, 5, 1])    ;   // Outcome: 30 ``` ### Absolute (abs) Returns the non-negative version of a number. ```javascript Math.abs(-7)   ;   // Outcome: 7 Math.abs(7)    ;   // Outcome: 7 ``` ### Maximum (max) Returns the highest number from a list. ```javascript Math.max(4, 11)               ;   // Outcome: 11 Math.max(1, 2, 1, 7, 9)       ;   // Outcome: 9 Math.max([1, 2, 1, 7, 9])     ;   // Outcome: 9 ``` ### Minimum (min) Returns the lowest number from a list. ```plaintext Math.min(4, 11)             ;   // Outcome: 4 Math.min(1, 2, 1, 7, 9)     ;   // Outcome: 1 Math.min([1, 2, 1, 7, 9])   ;   // Outcome: 1 ``` ### Average (avg) Calculates the arithmetic mean. Equivalent to the [mean](/v1/docs/imcscript-built-in-functions#mean-mean) fucntion. ```javascript Math.avg(4, 7)                     ;   // Outcome: 5.4 Math.avg(6, 4.5, 11.5, 2)          ;   // Outcome: 6 Math.avg([6, 4.5, 11.5, 2])        ;   // Outcome: 6 ``` ### Greatest common divisor (gcd) Returns the greatest common divisor (GCD) of the provided numbers. ```javascript Math.gcd(24, 18)             ;   // Outcome: 6 Math.gcd(50, 24, 18)         ;   // Outcome: 2 Math.gcd([50, 24, 18])       ;   // Outcome: 2 ``` ### Least common multiplier (lcm) Returns the least common multiplier (LCM) of the provided numbers. ```javascript Math.lcm(16, 4)                  ;   // Outcome: 16 Math.lcm(32, 12, 16, 2)          ;   // Outcome: 96 Math.lcm([32, 12, 16, 2])        ;   // Outcome: 96 ``` ## Convergence functions ### Round (round) Rounds a number to the specified number of decimal places. The default number of decimal places is 2. ```javascript Math.round(3.1345964, 4)     ;   // Outcome: 3.1346 Math.round(3.1345964)        ;   // Outcome: 3.13 ``` ### Ceiling (ceil) Rounds a number up to the next largest whole number or integer. Returns `0` and does not give a NaN error if the input is null. ```javascript Math.ceil(7.345)    ;   // Outcome: 8 Math.ceil(-7.345)   ;   // Outcome: -7 ``` ### Floor (floor) Returns the largest integer that is less than or equal to a given number. ```javascript Math.floor(7.345)    ;   // Outcome: 7 Math.floor(-7.345)   ;   // Outcome: -8 ``` ## Statistical functions ### Mean (mean) Calculates the arithmetic mean. Equivalent to the [avg](/v1/docs/imcscript-built-in-functions#average-avg) function. ```javascript Math.mean(4, 7)                      ;   // Outcome: 5.4 Math.mean(6, 4.5, 11.5, 2)           ;   // Outcome: 6 Math.mean([6, 4.5, 11.5, 2])         ;   // Outcome: 6 ``` ### Median (median) Returns the middle value from a sorted list. ```javascript Math.median(3, 2, 7, 1, 9, 2, 10)         ;   // Outcome: 3 Math.median(1, 2, 3, 4, 5, 6)             ;   // Outcome: 3.5 Math.median([1, 2, 3, 4, 5, 6])           ;   // Outcome: 3.5 ``` ### Mode (mode) Returns the most frequently occurring numbers. If there are multiple modes, the function returns them as an array. The function doesn’t guarantee the order of the returned values. ```javascript Math.mode(8, 2, 7, 2, 9, 2, 10)           ;   // Outcome: [2] Math.mode([1, 3, 3, 4, 2, 5, 2])          ;   // Outcome: [3, 2] Math.mode(1, 2, 3, 4, 5)                  ;   // Outcome: [] Math.mode(1, 1, 2, 2, 3, 3)               ;   // Outcome: [1, 2, 3] ``` ## Exponential Functions ### Power (pow) Raises a base number to a given exponent. ```javascript Math.pow(2, 3)        ;   // Outcome: 8 Math.pow(5, 2)        ;   // Outcome: 25 ``` ### Root (root) Returns the nth root of a number. If multiple roots exist, returns the positive root only. ```javascript Math.root(16, 4)      ;   // Outcome: 2 Math.root(3, 2)       ;   // Outcome: 1.7320508075688772 ``` ### Square (sq) Returns the square of a number. Equivalent to `pow(n,2)`. ```javascript Math.sq(3)            ;   // Outcome: 9 Math.sq(5)            ;   // Outcome: 25 ``` ### Square root (sqrt) Returns the square of a number. If multiple roots exist, returns the positive square root only. Equivalent to `root(n,2)`. ```javascript Math.sqrt(25)         ;   // Outcome: 5 Math.sqrt(2)          ;   // Outcome: 1.4142135623730951 ``` ### Cube root (cbrt) Returns the cube root of a number. Equivalent to `root(n, 3)`. ```javascript Math.cbrt(27)         ;   // Outcome: 3 Math.cbrt(15)         ;   // Outcome: 2.4662120743304703 ``` ## Trigonometric Functions ### Degree to radian (rad) Converts degrees to radians. ```javascript Math.rad(90)          ;   // Outcome: 1.5707963267948966 Math.rad(45)          ;   // Outcome: 0.7853981633974483 ``` ### Radian to degree (deg) Converts radians to degrees. ```javascript Math.deg(1.5707963267948966)    ;   // Outcome: 90 Math.deg(0.7853981633974483)    ;   // Outcome: 45 ``` ### Sine (sin) Returns the sine of a double. ```javascript Math.sin(0)                  ;   // Outcome: 0 Math.sin(Math.rad(45))       ;   // Outcome: 0.7071067811865475 ``` ### Cosine (cos) Returns the cosine of a double. ```javascript Math.cos(0)                  ;   // Outcome: 1 Math.cos(Math.rad(45))       ;   // Outcome: 0.7071067811865475 ``` ### Tangent (tan) Returns the tangent of a double. ```javascript Math.tan(0)                   ;   // Outcome: 0 Math.tan(Math.rad(45))       ;   // Outcome: 0.9999999999999999 ``` ### Arcsine (asin) Returns the arcsine of a double. This function is the inverse of the sine. ```javascript Math.asin(0.70)              ;   // Outcome: 0.775397496610753 Math.asin(Math.sin(1))       ;   // Outcome: 1 ``` ### Arc cosine (acos) Returns the arc cosine of a double. This function is the inverse of the cosine. ```javascript Math.acos(0.70)              ;   // Outcome: 0.7953988301841436 Math.acos(Math.cos(1))       ;   // Outcome: 1 ``` ### Arc tangent (atan) Returns the arc tangent of a double. This function is the inverse of the tangent. ```javascript Math.atan(0.70)              ;   // Outcome: 0.6107259643892086 Math.atan(Math.tan(1))       ;   // Outcome: 1 ``` ## Logarithmic Functions ### Logarithm (log) Calculates the logarithm of a number using the provided base. The default base is `e`—the base of natural algorithms. ```javascript Math.log(100, 10)            ;   // Outcome: 2 Math.log(Math.E)             ;   // Outcome: 1 ``` ### Base 10 logarithm (log10) Calculates the logarithm of a number using base 10. Equivalent to `log(n,10)`. ```javascript Math.log10(100)              ;   // Outcome: 2 Math.log10(30)               ;   // Outcome: 1.4771212547196624 ``` ## Parsing functions Parsing functions help parse one data type into another. ```javascript String.parse(5)              ;   // Outcome: "5" String.parse(3.12)           ;   // Outcome: "3.12" String.parse("Hello")        ;   // Outcome: "Hello" Integer.parse("5")           ;   // Outcome: 5 Integer.parse("5.12")        ;   // Outcome: 5 Integer.parse("A")           ;   // Outcome: FAILURE Double.parse("5")            ;   // Outcome: 5 Double.parse("5.12")         ;   // Outcome: 5.12 Double.parse("A")            ;   // Outcome: FAILURE ``` ## Check functions ### isFinite Returns `true` if the input is a finite number. Returns `false` in other cases, for example, if the input is `NaN` (not a number) or an infinity argument. ```javascript Math.isFinite(5)             ;   // Outcome: true Math.isFinite(NaN)           ;   // Outcome: false Math.isFinite(Math.log(0))   ;   // Outcome: false ``` ### isNan Returns `true` if the input is `NaN` (not a number). ```javascript Math.isNaN(5)                ;   // Outcome: false Math.isNaN(NaN)              ;   // Outcome: true Math.isNaN(Math.log(0))      ;   // Outcome: false ``` ## ExpressionBean functions ### intersection Returns the common elements between two ExpressionBeans. ```javascript var allSalesItems = Quote().includesSalesItem._objectName;   // ["SalesItem1", "SalesItem2"] var currSalesItem = SalesItem().objectName;                  // ["SalesItem2"] allSalesItems.intersection(currSalesItem);                   // Outcome: ["SalesItem2"] ``` ### subtraction Returns the elements present in one ExpressionBean but not in the other. ```javascript var allSalesItems = Quote().includesSalesItem._objectName;   // ["SalesItem1", "SalesItem2"] var currSalesItem = SalesItem().objectName;                  // ["SalesItem2"] allSalesItems.subtraction(currSalesItem);                    // Outcome: ["SalesItem1"] ``` ### union Combines all unique elements from ExpressionBeans into a single set. ```javascript var allSalesItems = Quote().includesSalesItem._objectName;   // ["SalesItem1", "SalesItem2"] var currQuote = Quote().objectName;                          // ["Quote1"] allSalesItems.union(currQuote);                              // Outcome: ["SalesItem1", "SalesItem2", "Quote1"] ``` ### contains Checks if an ExpressionBean contains a specific element. ```javascript var firstLevelISI = Quote().includesSalesItem[0]; var secondLevelISI = firstLevelISI.includesSalesItem[0]; var result  = Quote().includesSalesItem._contains(firstLevelISI);    // Outcome: true var result2 = firstLevelISI.contains(firstLevelISI);                 // Outcome: true var result3 = firstLevelISI.contains(secondLevelISI);                // Outcome: true ``` ### indexOf Returns the index of a specific element in the ExpressionBean. If the element doesn’t exist, it returns `-1`. ```javascript var firstLevelISI = Quote().includesSalesItem[0]; var secondLevelISI = firstLevelISI.includesSalesItem[0]; var result  = Quote().includesSalesItem._indexOf(firstLevelISI);     // Outcome: 0 var result2 = firstLevelISI.indexOf(firstLevelISI);                  // Outcome: 0 var result3 = firstLevelISI.indexOf(secondLevelISI);                 // Outcome: -1 ``` ### equals Checks whether two ExpressionBeans (either single objects or collections) are equivalent. Equivalent to the equality operator. ```javascript var allLevelISI     = Quote().includesSalesItem_; var firstLevelISI   = Quote().includesSalesItem[0]; var secondLevelISI  = firstLevelISI.includesSalesItem[0]; var result  = Quote().includesSalesItem_[0].equals(firstLevelISI);   // Outcome: true var result2 = Quote().includesSalesItem_[1].equals(firstLevelISI);   // Outcome: false var result3 = allLevelISI.equals(allLevelISI); ``` ### sort Sorts an ExpressionBean based on the provided IMCExpression, such as `this.salesItemPosition`, and a specified sort direction If you don’t enter an IMCExpression, the function uses the `ToString` method to sort. The default sort direction is `ASC`. ```javascript var salesItems = Quote().includesSalesItem_; // Outcome: ["Infield", "Open Field Project", "Submain"] var filteredSalesItems = salesItems.sort().objectName; // Outcome: ["Open Field Project", "Infield", "Submain"] var sortedSalesItems = salesItems.sort("this.salesItemPosition", "ASC").objectName; // Outcome: ["Submain", "Infield", "Open Field Project"] var sortedSalesItems2 = salesItems.sort("this.salesItemPosition", "DESC").objectName; ``` ### distinct Returns a collection of distinct elements from the ExpressionBean. ```javascript // Outcome: ["Infield", "Open Field Project", "Infield", "Infield", "Open Field Project"] var salesItems = Quote().includesSalesItem_.objectName; // Outcome: ["Infield", "Open Field Project"] var distinctSalesItems = Quote().includesSalesItem_.objectName.distinct(); ``` ### filter Filters the ExpressionBean based on the provided IMCExpression, such as `this.salesItemPosition`, and filter direction, including `ASC` (ascending) and `DESC` (descending). If you don’t enter an IMCExpression, the function uses the `ToString` method to filter. The default filter direction is `ASC`. ```javascript // Outcome: ["Open Field Project", "Infield"] var salesItems = Quote().includesSalesItem_.objectName; // Outcome: ["Infield"] var filteredSalesItems = Quote().includesSalesItem_.filter("this.isProduct.objectName.contains('Infield')").objectName; ``` ### size Returns the number of elements in the ExpressionBean. ```javascript var salesItems = Quote().includesSalesItem_; var result = salesItems.size();    // Outcome: 2 ``` ## ExpressionBean (SalesItem) functions The ExpressionBean library includes special methods that apply only to SalesItem ExpressionBeans. These functions cover two key areas: - Dynamic attributes (DA) - Google Maps Integration ## Dynamic attribute (DA) methods The following code block contains the [dynamic attribute](/v1/docs/about-dynamic-attributes) (DA) methods with comments: ```javascript // READ SalesItem().getDA();                               // Returns all DAs connected to SalesItem SalesItem().getDA("DA1")[0];                       // Returns DA 'DA1' SalesItem().getDA()[0];                            // Same as getDA("DA1") : Fetches all DAs connected to SalesItem SalesItem().getDAValue("DA1");                     // Returns all DA values connected to 'DA1' SalesItem().getDSAValueLabel();                    // Returns DSA value labels connected to SalesItem SalesItem().getDSAValueLabel('DSA1')[0];           // Returns DSA value label for DSA 'DSA1' SalesItem().getDAObjectNames();                    // Returns all DA objectNames SalesItem().getDACurrency();                       // Returns all currencies connected to SalesItem SalesItem().getDACurrency('DA1')[0];               // Returns currency for DA 'DA1' SalesItem().getDAMandatory();                      // Returns all mandatory values for SalesItem SalesItem().getDAMandatory('DA1')[0];              // Returns mandatory value for DA 'DA1' SalesItem().getDAHidden();                         // Returns all hidden DAs SalesItem().getDAHidden('DA1')[0];                 // Returns hidden value for DA 'DA1' SalesItem().getDAReadonly();                       // Returns all readonly DAs SalesItem().getDAReadonly('DA1')[0];               // Returns readonly value for DA 'DA1' SalesItem().getDAType();                           // Returns type (String/Number/...) of all DAs SalesItem().getDAType('DA1');                      // Returns dataType(String/Number/...) of DA 'DA1' SalesItem().getDSAValueThumbnail('DSA1');          // Returns DSA value thumbnail of DSA 'DSA1' SalesItem().getDSAValueLabel('DA1', Lang.GERMAN);  // Returns DSA value label in German for DSA 'DSA1' SalesItem().getDSAValueLabel('DA1', 'en-IN');      // Returns DSA value label in English (India) for DSA 'DSA1' // UPDATE SalesItem().setDAValue("DA1", "Apple");            // Sets DA value to 'Apple' for DynamicAttribute 'DA1' SalesItem().setDAValue("DSA1", "Apple");           // Sets DSA value for DynamicAttribute - 'DSA1' SalesItem().setDADisabled("DA1", true);            // Hides DynamicAttribute - 'DA1' SalesItem().setDADisabled("DA1", false);           // Shows DynamicAttribute - 'DA1' SalesItem().setDAMandatory("DA1", true);           // Sets DynamicAttribute - 'DA1' to be mandatory SalesItem().setDAMandatory("DA1", false);          // Sets DynamicAttribute - 'DA1' to be non-mandatory SalesItem().setDACurrency("DA1", SGD);             // Sets currency unit to SGD for 'DA1' ``` ### getGeoJSON The following Google Maps-specific method is available: ```javascript SalesItem().getGeoJSON();        // Returns GeoJSON object connected to SalesItem ``` ### GeoJSON functions GeoJSON is a standardized format for encoding geographic data structures. In CPQ, this format is used to store features drawn on Google Maps in a quote. To view the GeoJSON data of a map, select the **Download** button at the bottom-left corner of the map window. ![image.png](https://cdn.document360.io/24f960e8-3c1c-4c18-a2c6-83b6ae4aab84/Images/Documentation/image%28375%29.png?sv=2026-02-06&spr=https&st=2026-11-11T12%3A55%3A00Z&se=2026-11-11T13%3A55%3A00Z&sr=c&sp=r&sig=0PrUpdhlszL903kyDJJ5vUVRnqq2LGiVicd6Pm7fpuU%3D) The downloaded file has a `.json` extension, and you can open it with any text editor. In the file, each feature in the map, such as marker, line, or polygon, is listed under the `features` array in the JSON file. Every entry includes the following parameters: - `geometry`—Shape, such as marker, line, or polygon, and its coordinates, including latitude and longitude. - `properties`—Custom metadata associated with the feature. Features can be identified either by their ID (used for predefined objects such as the normalized rectangle or slope arrow) or by their assigned type. Sample JSON file with GeoJSON data of a map: ```javascript {  "type": "FeatureCollection",  "features": [    {      "type": "Feature",      "geometry": {        "type": "Polygon",        "coordinates": [          [103.84041768669431, 1.2913703203558677],          [103.83363706230466, 1.28001293311410187],          [103.86814095907224, 1.2753669124258291],          [103.86942845939393, 1.287852153483418],          [103.84041768669431, 1.2913703203558677]        ]      },      "properties": {        "isPoly": true,        "area": 487.4,        "perimeter": 9987,        "type": "http://www.inmindcloud.com/application/schema.owl#GeoField"      },      "id": "dc446d54-946c-4d89-a39a-88426062ceff"    },    {      "type": "Feature",      "geometry": {        "type": "Point",        "coordinates": [103.83110505695946, 1.2951450986549664]      },      "properties": {        "isPoint": true      }    }  ] } ``` ### isFeaturePresent Checks whether a specific feature exists on the map. You can identify a feature by either its ID or its type URI. ```javascript var as = "http://www.inmindcloud.com/application/schema.owl#"; var feature_id = "normalized_rect"; var field_uri = as + "GeoField"; var geoJson = SalesItem().getGeoJSON(); // Check if feature exists using feature ID if (geoJson.isFeaturePresent(feature_id)) {  // Work on Google rectangle now that we are sure it exists } // Check if feature exists using URI if (geoJson.isFeaturePresent(field_uri)) {  // Work on Google rectangle now that we are sure it exists } ``` ### getProperty Retrieves the value of a custom property from a specific feature. If the feature doesn’t exist or the property isn’t available, the function returns an empty result. For point features, such as markers, this function also accepts **latitude** and **longitude** as property names to return the coordinates, even though these aren’t stored as standard custom properties. ```javascript var geojson = SalesItem().getGeoJSON(); var area = geojson.getProperty('normalized_rect', 'area'); ``` ## LookupTable Functions ### table Defines the lookup table to retrieve data from. Use this function before using the `search` or `searchOn` functions, otherwise the script will fail. It returns `DBLookupTable`, allowing method chaining. ```javascript var table = DBLookupTable.table('table1');  // Outcome: DBLookupTable instance with name 'table1' table.addSelectFields('field1', 'field2').search(); ``` ### addSelectFields Specifies which fields to retrieve from the lookup table. You can pass one or more field names as input. This function is optional. If you don’t use it, all fields will be retrieved by default. This function returns `DBLookupTable`, allowing method chaining. > [!WARNING] > Note > > Calling this method a second time will overwrite the previous selection. ```javascript // Retrieve all fields DBLookupTable.table('table1')  .search(); // Overwrites previous select fields; only 'field3' is retrieved DBLookupTable.table('table1')  .addSelectFields('field1', 'field2')  .addSelectFields('field3')  .search(); ``` ### addCondition Applies one or more filter conditions to the lookup table. Each call adds a new condition, and all conditions are combined using the `AND` logic. If you don’t use this function, all records from the table will be retrieved without filtering. This method supports all conditional operators except ternary. Using unsupported operators will result in a script failure. This function returns `DBLookupTable`, allowing method chaining. ```javascript // Retrieve only records that meet both conditions DBLookupTable.table('table1')  .addCondition('field1', '==', 100)  .addCondition('field2', '==', 'ABC')  .search(); ``` ### addOrderBy Defines how the lookup results should be sorted. You can specify multiple sort fields, and the sort is applied in the order they are defined. If you don’t use this function, the system sorts records by ID by default. Accepted sort directions are `ASC` (ascending) or `DESC` (descending). This function returns `DBLookupTable`, allowing method chaining. ```javascript // Retrieve records ordered by field1 in ascending order, then by field2 in descending order DBLookupTable.table('table1')  .addOrderBy('field1', 'ASC')  .addOrderBy('field2', 'DESC')  .search(); ``` ### search Retrieves data from the specified lookup table using any previously defined conditions. Returns the result as a list, even if only one record matches the criteria. ```javascript // Retrieve all data in the table var data = DBLookupTable.table('table1').search(); // Access the value of 'field1' for the first record var value = data[0]['field1']; ``` ### searchOne Retrieves the first matching record from the lookup table based on the defined conditions and sort order. Returns the result as a map. If multiple records match, only the first one is returned. ```javascript // Retrieve the first record in the table var data = DBLookupTable.table('table1').searchOne(); // Access the value of 'field1' for the first record var value = data['field1']; ``` ## System Functions ### log Logs a message to the IMCScript audit log. Supported log types: `ERROR`, `WARNING`, and `INFO`. ```javascript System.log('This is an error message', 'ERROR');    // Error message will be logged - RED color System.log('This is a warning message', 'WARNING'); // Warning message will be logged - BLUE color System.log('This is an information message', 'INFO'); // Information message will be logged - BLACK color ``` ### push Displays a UI notification of the specified type: `ERROR`, `WARNING`, or `INFO`. ```javascript System.push('This is an error message', 'ERROR');     // An error message will be pushed in notification System.push('This is a warning message', 'WARNING');  // A warning message will be pushed in notification System.push('This is an information message', 'INFO'); // An info message will be pushed in notification ``` ## List Functions ### add Adds an element to the list. ```javascript var emptyList = List.create();    // --> [] list.add(5);                      // --> [5] list.add(8);                      // --> [5, 8] ``` ### delete Deletes an element from the list. ```javascript var list = List.create(3, 4, 6, 7);   list.delete(4);     // --> [3, 6, 7] list.delete(5);     // --> [3, 6, 7] list.delete(6);     // --> [3, 7] ``` ### deleteAt Deletes the element at the specified index from the list. ```javascript var list = List.create(3, 4, 6, 7); list.deleteAt(1);   // --> [3, 6, 7] list.deleteAt(5);   // --> Failure ``` ### contains Checks whether the list contains a specific element. ```javascript var list = List.create(4, 5, 6, 7, 8); var result  = list.contains(5);   // Outcome: true var result2 = list.contains(10);  // Outcome: false ``` ### indexOf Returns the index of a specified element in the list. If the element doesn’t exist, the function returns `-1`. ```javascript var list = List.create(4, 5, 6, 7, 8); var result  = list.indexOf(5);    // Outcome: 1 var result2 = list.indexOf(10);   // Outcome: -1 ``` ### equals Checks whether two lists are equivalent. This is functionally the same as using the equality operator. ```javascript var list  = List.create(4, 5, 6, 7, 8); var list2 = List.create(4, 5, 6, 7, 8, 8); var result  = list.equals(list);   // Outcome: true var result2 = list.equals(list2);  // Outcome: false ``` ### sort Sorts the list in the specified direction: `ASC` (ascending) or `DESC` (descending). The default direction is ascending. ```javascript var list = List.create(5, 4, 2, 8, 4, 9, 4); // Outcome: [2, 4, 4, 4, 5, 8, 9] var sortedList = list.sort(); // Outcome: [9, 8, 5, 4, 4, 4, 2] var sortedList2 = list.sort("DESC"); ``` ### distinct Returns a list of unique elements. ```javascript var list = List.create(3, 4, 7, 4, 6, 7);   // --> [3, 4, 7, 4, 6, 7] return list.distinct();                     // --> [3, 4, 7, 6] ``` ### size Returns the number of elements in the list. ```javascript var list        =   List.create(4,5,6,7,8);                                       var result      =   list.size();            // Outcome: 5 ``` ## Map Functions ### add Adds a key-value pair to the map. ```javascript var map         =   Map.create();           // --> {} map.add('A','Apple') ;                      // --> {'A':'Apple'} map.add('B','Banana');                      // --> {'A':'Apple','B':'Banana'} ``` ### keys Returns a list of all keys in the map. ```javascript var map         =   Map.create();           // --> {} map.add('A','Apple') ;                      // --> {'A':'Apple'} map.add('B','Banana');                      // --> {'A':'Apple','B':'Banana'} map.keys();                                 // Outcome: ["A","B"] ``` ### values Returns a list of all values in the map. ```javascript var map         =   Map.create();           // --> {} map.add('A','Apple') ;                      // --> {'A':'Apple'} map.add('B','Banana');                      // --> {'A':'Apple','B':'Banana'} map.values();                               // Outcome: ["Apple","Banana"] ``` ### size Returns the number of key-value pairs in the map. ```javascript var map         =   Map.create();           // --> {} map.add('A','Apple') ;                      // --> {'A':'Apple'} map.add('B','Banana');                      // --> {'A':'Apple','B':'Banana'} map.size();                                 // Outcome: 2 ```