JS: Most optimized way to remove a filename from a path in a string?
#javascript #optimizationUse lastIndexOf() to find the position of the last slash and get the part before the slash with substring().
str.substring(0, str.lastIndexOf("/"))
Use lastIndexOf() to find the position of the last slash and get the part before the slash with substring().
str.substring(0, str.lastIndexOf("/"))
Close the knowledge gap between you and your clients!