Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
知られているようで知られていない JavaScriptの仕様 4選
Search
syumai
November 14, 2025
Programming
1.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
知られているようで知られていない JavaScriptの仕様 4選
syumai
November 14, 2025
More Decks by syumai
See All by syumai
Workers Cache を知る
syumai
0
330
自分的「カンファレンスの楽しみ方」
syumai
0
220
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.6k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
2k
Oxlintのカスタムルールの現況
syumai
6
2.1k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1.6k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
640
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.4k
CloudflareのSandbox SDKを試してみた
syumai
0
1.1k
Other Decks in Programming
See All in Programming
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
150
AWSに止められる覚悟してますか?
morizo_1984
2
510
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
550
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
230
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
320
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
440
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
390
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
340
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
190
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.8k
iOSDC2026登壇資料.pdf
riofujimon
0
210
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
740
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
330
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Embracing the Ebb and Flow
colly
88
5.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
860
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
So, you think you're a good person
axbom
PRO
2
2.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
My Coaching Mixtape
mlcsv
0
340
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Transcript
知られているようで知られていない JavaScriptの仕様 4選 syumai YACP::Fukuoka *S Tech Talks (2025/11/15)
自己紹介 syumai ECMAScript 仕様輪読会 / Asakusa.go 主催 Software Design 2023年12月号から2025年2月号まで
Cloudflare Workersの連載をしました Twitter (現𝕏): @__syumai Website: https://syum.ai
カンマ演算子
カンマ演算子 , の前後に式を受け取り、後ろの式の値を演算結果とする演算子 console.log((1, 2)); // 2 console.log(((1, 2), 3));
// 3 console.log((1, (2, 3), 4)); // 4
カンマ演算子 ある変数への操作を行った直後にその値を返したい時などに使える 大体の場合は文を分ければいいので、ほぼ出番がない const f = (a) => { let
x = 0; return (x += a, x); // 変数を操作した直後に返却 }
カンマ演算子 2重配列を操作するfor文を1本で書きたい時とかに使えるらしい // 例 for (let i = 0, j
= 9; i <= 9; i++, j--) { console.log(`a[${i}][${j}] = ${a[i][j]}`); } for ( // ここは普通の変数宣言 let i = 0, j = 9; i <= 9; // ここがカンマ演算子 i++, j-- ) { console.log(`a[${i}][${j}] = ${a[i][j]}`); } https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Comma _operator#for_ループでのカンマ演算子の使用
カンマ演算子 関数オブジェクトにnameを持たせたくない時にも使える カンマ演算子を使えば、即時実行関数を使わなくていい const f1 = () => {}; //
宣言時に勝手に関数のnameに "f1" が設定される const f2 = (0, () => {}); // 式として評価してから代入しているので設定されない const f3 = (() => {})(); // 即時実行関数で評価してから代入しているので同様 console.log( f1.name, // "f1" f2.name, // "" f3.name, // "" );
direct eval / indirect eval
direct eval / indirect eval JavaScriptの世界には、2つの種類のevalがある direct eval indirect eval
これらの違いを知っていますか? function f() { let a = 0; eval("a = 1;"); // direct eval const _eval = eval; _eval("a = 2;"); // indirect eval }
direct eval / indirect eval direct evalは今のスコープを、indirect evalはグローバルスコープを操作する function f()
{ let a = 0; eval("a = 1;"); // direct eval const _eval = eval; _eval("a = 2;"); // indirect eval console.log(a); // 1 console.log(globalThis.a); // 2 }
indirect evalの入手方法 indirect evalは、 eval を一度式として評価することで入手できる カンマ演算子、optional chainなどが使える function f()
{ // いずれも indirect eval (0, eval)("a = 1;"); eval?.("b = 1;"); }
indirect eval、いつ使うのか? (そもそもユーザーが記述したコードの実行にevalは使うべきじゃない前提 で、)eval呼び出しに渡されるコードから、関数スコープの変数を見せたくない 時に使える!
Directive Prologue
この関数はstrict mode扱いになる (function() { "use strict"; with ({}) {} //
strict modeでは使えない })();
次の関数はstrict mode扱いになるか? (function() { "use not strict"; "use strict"; with
({}) {} // ? })();
答え: strict mode扱いになる
strict mode扱いになる (function() { "use not strict"; "use strict"; //
ちゃんとここのディレクティブが効く! with ({}) {} })();
Directive Prologuesの定義 Directive Prologuesは、関数、スクリプト、モジュールの冒頭に続く最長の文字列 リテラルトークンの列でしかない その途中にどんな文字列が含まれたっていい https://tc39.es/ecma262/multipage/ecmascript-language-source-code.html#sec- directive-prologues-and-the-use-strict-directive
有効なDirective Prologuesの例 (function() { "あいうえお"; 'abcde' // 明示的にセミコロンを打ったら、1行に書いてもOK "use hoge"
// セミコロンを書かなくても、自動セミコロン挿入されるのでOK "" // 空文字もOK '' // シングルクォートもOK "use strict" // これが効く! 'use fuga' // 後ろに続いててもOK with ({}) {} // strict modeなのでwith文は使えない })();
無効なDirective Prologuesの例 ディレクティブの間に文字列以外のトークンがあると、「連続した文字列リテラ ルトークン」であるという条件が満たされない (function() { "use not strict"; 1;
"use strict"; with ({}) {} // strict modeではないので、with文が使える })();
無効なDirective Prologuesの例 ` はテンプレートリテラルであって、文字列リテラルではないので、Directive Prologuesになれない (function() { `use strict`; with
({}) {} // strict modeではないので、with文が使える })();
undefined扱いのObject
typeof document.all が undefined なのに document.all === undefined が false
!?
https://developer.mozilla.org/ja/docs/Web/API/Document/all
ECMAScriptのObjectの仕様上で、 document dot all の専用の内部フィールド、 [[IsHTMLDDA]] が定義されている https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web- browsers.html#sec-IsHTMLDDA-internal-slot
typeof に、Objectに [[IsHTMLDDA]] フィールドがあるときに "undefined" という 文字列を返すオプショナルな仕様がある https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec- typeof-operator
jkr_2255さんの記事 https://qiita.com/jkr_2255/items/f9b7218d7a2b54424c12
ご清聴ありがとうございました!