file in abyss
フォーマット一覧へ戻る

Code

JS JavaScript

WebやNode.jsで広く使われるプログラミング言語のソースファイル。固定のバイナリシグネチャはありません。

Extensions .js, .mjs, .cjs
MIME text/javascript, application/javascript

マジックナンバー

ファイルを解析
オフセット 0 ES module exportで始まるJavaScriptサンプル
65 78 70 6F 72 74
export

構造

  1. Statements
  2. Declarations
  3. Expressions
  4. Modules

注意点

  • JavaScript一般には固定マジックナンバーがなく、拡張子・MIME・パーサーで判定します。

判定コード例

SIGNATURE = bytes.fromhex("6578706f7274")
OFFSET = 0

def is_js(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

JavaScript はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。

よくある判定ミス

  • .js / .mjs / .cjs という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • JavaScript は 65 78 70 6F 72 74 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

形式が判定できたからといって、信頼できない入力が安全とは限りません。パーサ例外・巨大ファイル・想定外のエンコーディング・外部参照を考慮してください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Code

Blue Sky JS

Blue Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.js
Type Sample
Small file
289 B
SHA-256 7d3b2994ee0a1c9c28837d0ba8de3ec918b7820baa1291e49ef20c85c9a343ff
Download
Code

Flower Garden JS

Flower Garden JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.js
Type Sample
Small file
314 B
SHA-256 e4e0e31904121880833d098f0ece7e5f03c7a87c9e8bfc347620f2b0edd23755
Download
Code

Navy Blue Sky JS

Navy Blue Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.js
Type Sample
Small file
306 B
SHA-256 68a18b0a81d6a381122fdca7a48615cccef3e9321b56eb3d848906446faef1a8
Download
Code

Nature of the Sky JS

Nature of the Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.js
Type Sample
Small file
298 B
SHA-256 88f8a8495116ba8f94009b85973fe8d1682fbd9df9858f078a8a16bb8cf419c6
Download
Code

Sky Landscape JS

Sky Landscape JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.js
Type Sample
Small file
315 B
SHA-256 12c8c7523d5e78f0eef8f10c99b51f90230c44c290ae8f54d560f64222c70772
Download
Code

Starry Sky JS

Starry Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.js
Type Sample
Small file
298 B
SHA-256 d0a79f3af31aac614a4aa57699d5916597a604ad7f46e9e46d6d70f52ba5cc78
Download
Code

Blue Night Sky JS

Blue Night Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.js
Type Sample
Small file
292 B
SHA-256 d172ade12c1b20dc0894883054a56a48036c23d954ae2d33c29e75323ed99492
Download
Code

Hibiscus Flower JS

Hibiscus Flower JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.js
Type Sample
Small file
319 B
SHA-256 add6427d73d92168b6c82a494d5767ab535830a8800de179191eca218c1dcd47
Download
Code

Arctic Sky JS

Arctic Sky JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.js
Type Sample
Small file
300 B
SHA-256 faec434d8db0ad7ebc4aa173410aa473e07ff40afb5e9f79f1e7ed9e40b75c0a
Download
Code

Sunset Rays JS

Sunset Rays JS is a JavaScript sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

10-sunset-rays.js
Type Sample
Small file
303 B
SHA-256 ff8d74f4347a005c4c07e4e0c1914439b5b893d81328fd483c378ad2efd7324a
Download
Code

NASA Blue Marble JS

NASA Blue Marble JS is a JavaScript sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.js
Type Sample
Small file
354 B
SHA-256 83674dbcffe0c1c778f58bac76805f2f5b1f6399e064a9ec50feba9c7624cdf2
Download

よくある質問

JavaScript のマジックナンバー(ファイルシグネチャ)は?

JavaScript ファイルはバイトシグネチャ 65 78 70 6F 72 74 ("export") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

JavaScript のMIMEタイプは?

JavaScript のMIMEタイプは text/javascript, application/javascript です。

JavaScript の拡張子は?

JavaScript ファイルは .js, .mjs, .cjs 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。