Javascript - Lấy phần mở rộng của tập tin

Lấy phần mở rộng của tập tin

Viết một chương trình JavaScript để lấy phần mở rộng của tập tin.

Mã nguồn:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>The extension of a filename.</title>
  <script>
   filename = "system.php"
   document.write(filename.split('.').pop());
   filename = "abc.js"
   document.write(filename.split('.').pop());
  </script>
</head>
<body>

</body>
</html>

Xem ví dụ