问题
I trying to remove array square bracket at beginning and end.
EX: [['moe', 30], ['larry', 40], ['curly', 50]]
Need: ['moe', 30], ['larry', 40], ['curly', 50]
回答1:
If it is a string you can use the substring
or slice
method like this:
var yourString = "[['moe', 30], ['larry', 40], ['curly', 50]]";
// using substring
var result = yourString.substring(1, yourString.length-1);
console.log(result);
// using slice
var result2 = yourString.slice(1, -1);
console.log(result2);
来源:https://stackoverflow.com/questions/49895931/remove-square-brackets-at-beginning-and-ending-using-undersore-or-javascript