Question: What's the **JavaScript** equivalent to this `C#` Method:

```
var x = "|f|oo||"; 
var y = x.Trim('|'); //  "f|oo"

```

C# trims the selected character only at the **beginning** and **end** of the string!

Answer: 
If I understood well, you want to remove a specific character only if it is at the beginning or at the end of the string (ex: `||fo||oo||||` should become `foo||oo`). You can create an ad hoc function as follows:

```
function trimChar(string, charToRemove) {
    while(string.charAt(0)==charToRemove) {
        string = string.substring(1);
    }

    while(string.charAt(string.length-1)==charToRemove) {
        string = string.substring(0,string.length-1);
    }

    return string;
}

```

I tested this function with the code below:

```
var str = "|f|oo||";
$( "#original" ).html( "Original String: '" + str + "'" );
$( "#trimmed" ).html( "Trimmed: '" + trimChar(str, "|") + "'" );

```
To my knowledge, jQuery doesnt have a built in function the method your are asking about.
With javascript however, you can just use replace to change the content of your string:

```
x.replace(/|/i, ""));

```

This will replace all occurences of | with nothing.