exclude extension from filename javascript

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

Also in JavaScript: