Skip to content Skip to sidebar Skip to footer

Remove Square Brackets At Beginning And Ending Using Undersore Or Javascript

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]

Solution 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);

Post a Comment for "Remove Square Brackets At Beginning And Ending Using Undersore Or Javascript"