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
230
自分的「カンファレンスの楽しみ方」
syumai
0
210
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.9k
Oxlintのカスタムルールの現況
syumai
6
2.1k
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
1.6k
『[入門] Cloudflare Workers』本はなぜ誕生したのか
syumai
0
610
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
9
3.3k
CloudflareのSandbox SDKを試してみた
syumai
0
1.1k
Other Decks in Programming
See All in Programming
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
360
The Rails Doctrine Decade
koic
2
370
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
480
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
2
300
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
510
Family mrubyの進捗
kishima
1
130
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.5k
JRuby: Past, Present, and Future
headius
0
190
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
4
3.7k
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
200
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.4k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
350
Featured
See All Featured
New Earth Scene 8
popppiees
4
2.6k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Raft: Consensus for Rubyists
vanstee
142
7.7k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
290
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
WENDY [Excerpt]
tessaabrams
14
39k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
HDC tutorial
michielstock
2
900
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
ご清聴ありがとうございました!