Javascript examples for Array Operation:Array Convert
Convert String to array then remove last element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w ww .j a v a 2 s . c o m var path = "/bar/foo/moo/"; var split = path.split("/"); var x = split.slice(0, split.length - 2).join("/") + "/"; console.log(x); }); </script> </head> <body> </body> </html>