Question: Trying to implement something like this:

```
arr = (1..10)

arr[2,5] = [2,3,4,5]
arr(2,5] = [3,4,5]
arr[2,5) = [2,3,4]
arr(2,5) = [3,4]

```

Well, we need to override four bracket opreators: [], [), (], ()

Any ideas?

It's called "Including or excluding" in mathematics. <https://en.wikipedia.org/wiki/Interval_(mathematics)#Including_or_excluding_endpoints>

Answer: 
I am way late and a dollar short, but here is another solution. I was looking for a quick answer before stumbling across it Intellisense. It sounds like you are looking for ClearScript's "Invoke" method:

Given that you might have a JavaScript function like:

```
function calculation(a) {
    var b = a[0];
    var c = a[1];
    var d = a[2];
    var e = a[3];

    return `{{ one: ${(b + c)}, two: ${(d + e)} }}`;
};

```

That you wish to call from C# with an array of ints:

```
var rtnstr = engine.Invoke("calculation", new int[] { 1, 2, 3, 4, 5 });

```

Possible bug in ClearScript 5.6: It does not seem to like function variables. I originally tried to declare the function as:

```
const calculation = (a) => {
    var b = a[0];
    var c = a[1];
    var d = a[2];
    var e = a[3];

    return `{{ one: ${(b + c)}, two: ${(d + e)} }}`;
};

```

But I received an exception "Method or property not found". Declaring as a plain old function in the global scope works though.
I don't know if you still need this, but I stumbled upon your question and gave it a shot.

First add a JS file to your solution:

[Add a javascript file to your solution.](https://i.stack.imgur.com/G1Avm.png)

Then add your javascript to the javascript file:

```
var myArray = [0,1,2,3];
var a = myArray[0];
var b = myArray[1];
var c = myArray[2];
var d = myArray[3];
var rtnstr = "{errmsg: 'calculation never ran'}";

function calculation() {
   var one = a + b;
   var two = c + d;
   rtnstr = "{ one:'" + one  + "', two:'" + two + "'}";
   return rtnstr;
}

```

In your C# code then do something like the following:

```
using System;
using System.IO;
using Microsoft.ClearScript.V8;

namespace ClearScriptConsole
{
    class Program
    {
        static void Main(string[] args) {

            V8ScriptEngine _v8Engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging);

            string jsFilePath = @"..\..\HelloWorld.js";
            string jsContents = File.ReadAllText(jsFilePath);

            _v8Engine.Execute(jsContents);

            var returnedVal = _v8Engine.Script.calculation();
            Console.WriteLine(returnedVal);
        }
    }
}

```

And the returned value gave me the following:

[The result of the calculation displayed in a console window.](https://i.stack.imgur.com/npWfW.png)

Cheers