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: 
A regex-less version which is easy on the eye:

```
const trim = (str, chars) => str.split(chars).filter(Boolean).join(chars);

```

For use cases where we're certain that there's no repetition of the chars off the edges.
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.