📜  获取文件扩展名 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:45.644000             🧑  作者: Mango

代码示例5
function getExtension(filename) {
  return filename.substring(filename.lastIndexOf(".") + 1);
}

let filename = "main.config.js";
let extension = getExtension(filename);
console.log(extension); // "js"

let photoname = "photo.jpg";
let photoExtension = getExtension(photoname);
console.log(photoExtension); // "jpg"