javascript remove extension from filename

77

exclude extension from filename javascript -

const file = 'test.jpg';
const filename = file.split('.').slice(0, -1).join('.');

javascript remove extension from filename -

// using string methods only
filename.substring(0, filename.lastIndexOf('.')) || filename

// using both string & array methods
filename.split('.').slice(0, -1).join('.')

Comments

Submit
0 Comments