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
shobon-kun-no-module-hogehoge
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mamoida
November 13, 2013
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
shobon-kun-no-module-hogehoge
mamoida
November 13, 2013
Other Decks in Programming
See All in Programming
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
360
Hono + Inertia + React で LP を構築した話
oukayuka
2
220
高専キャリア LT 発表内容
crysta1221
6
5.6k
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
260
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
420
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
130
typoなんかねぇよ
raspython3
0
680
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
320
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
130
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
190
フロントエンドUIフレームワークのこれまでとこれから
ssssota
3
1.4k
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.6k
Featured
See All Featured
Between Models and Reality
mayunak
4
450
Deep Space Network (abreviated)
tonyrice
0
300
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
520
Ethics towards AI in product and experience design
skipperchong
2
370
Designing for humans not robots
tammielis
254
26k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
580
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Leo the Paperboy
mayatellez
8
2.3k
Faster Mobile Websites
deanohume
310
32k
Transcript
(´ 3 `) Created by @mamoida
(´ 3 `) <
(´ 3 `) <
(function(win){ win.myModule = { some : function(){ console.log('some'); } };
})(window);
(´ 3 `) <
myModule.some(); // some
(´ 3 `) <
(´ 3 `) < node
$ node main.js ReferenceError: window is not defined
(´ 3 `) <
(´ 3 `) < node window
(´ 3 `) < window this
(function(root){ console.log(root); })(this);
Window {top: Window, window: Window, location: Location, external: Object, chrome:
Object⋯}
(´ 3 `) < window
$ node main.js {}
(´ 3 `) <
(´ 3 `) < this
(function(root){ console.log(this); })(this);
$ node main.js { ArrayBuffer: [Function: ArrayBuffer], Int8Array: { [Function:
Int8Array] BYTES_PER_ELEMENT: 1 }, Uint8Array: { [Function: Uint8Array] BYTES_PER_ELEMENT: 1 }, Uint8ClampedArray: { [Function: Uint8ClampedArray] BYTES_PER_ELEMENT: 1 }, Int16Array: { [Function: Int16Array] BYTES_PER_ELEMENT: 2 }, Uint16Array: { [Function: Uint16Array] BYTES_PER_ELEMENT: 2 }, Int32Array: { [Function: Int32Array] BYTES_PER_ELEMENT: 4 }, Uint32Array: { [Function: Uint32Array] BYTES_PER_ELEMENT: 4 }, Float32Array: { [Function: Float32Array] BYTES_PER_ELEMENT: 4 }, Float64Array: { [Function: Float64Array] BYTES_PER_ELEMENT: 8 }, ...
(´ 3 `) <
(´ 3 `) < node
var self = (function(root){ console.log(root === this); //false console.log(this.setTimeout); //[Function]
return this; })(this); console.log(self === this); // false console.log(this.setTimeout); // undefined console.log(setTimeout); // [Function]
(´ 3 `) < ...
(function(root){ console.log(typeof root.module); //undefined console.log(typeof module); //object console.log(typeof root.exports); //undefined
console.log(typeof exports); //object })(this); console.log(typeof this.module); //undefined console.log(typeof module); //object console.log(typeof root.exports); //undefined console.log(typeof exports); //object
module ( ) exports ( )
(´ 3 `) <
(´ 3 `) < exports node
(function(root){ if(typeof exports === 'object'){ module.exports = { some: function(){
console.log('some'); } }; }else{ root.myModule = { some: function(){ console.log('some'); } }; } })(this);
(´ 3 `) <
myModule.some(); // some
(´ 3 `) < node require
var myModule = require('./module.js'); myModule.some(); //some
(´ 3 `) < 2
(function(root){ var myModule = { some: function(){ console.log('some'); } };
if(typeof exports === 'object'){ module.exports = myModule; }else{ root.myModule = myModule; } })(this);
(´ 3 `) < AMD
(´ 3 `) < AMD ?
define.amd = {}; define(id?, dependencies? , factory)
define(['underscore'] , function(_){ return {}; });
(´ 3 `) < require.js
script(src="/js/lib/require.js")
(function(root){ console.log(typeof root.define); //function console.log(typeof root.define.amd); //object console.log(typeof root.require); //function
})(this);
(´ 3 `) <
(´ 3 `) <
(function(root){ var myModule = { some: function(){ console.log('some'); } };
if(typeof root.define === 'function' && define.amd){ define([],myModule); }else if(typeof exports === 'object'){ module.exports = myModule; }else{ root.myModule = myModule; } })(this);
(´ 3 `) < html
require.config({ baseUrl: '/js/', paths : {} }); require(['myModule'],function(myModule){ myModule.some(); });
(´ 3 `) <
(´ 3 `) <
(´ 3 `) < underscore
(function(root){ var myModule = { some: function(){ console.log('some'); } };
if(typeof root.define === 'function' && define.amd){ define(['underscore'],function(_){ return myModule; }); }else if(typeof exports === 'object'){ var underscore = require('underscore'); module.exports = function(underscore){ return myModule; }; }else{ root.myModule = function(_){ return myModule; }; } })(this);
(´ 3 `) <
(function(){ require.config({ baseUrl: '/js/', paths : { underscore : 'lib/underscore'
} }); require(['myModule'],function(myModule){ myModule.some(); }); })();
(´ 3 `) <
(function(root,factory){ if(typeof root.define === 'function' && define.amd){ define(['underscore'],factory); }else if(typeof
exports === 'object'){ module.exports = factory(require('underscore')); }else{ root.myModule = factory(_); } })(this,function(_){ var myModule = { some: function(){ console.log('some'); }, //メソッド追加 isArray : function(obj){ return _.isArray(obj); } }; return myModule; });
// browser with AMD (function(){ require.config({ baseUrl: '/js/', paths :
{ underscore : 'lib/underscore' } }); require(['myModule'],function(myModule){ myModule.some(); // some myModule.isArray({}); // false }); })();
// browser export script(src="/js/lib/underscore.js") script(src="/js/myModule.js") script. (function(){ myModule.some(); // some
myModule.isArray({}); // false })();
(´ 3 `) <
(´ 3 `) <
None
AMD · amdjs/amdjs-api Wiki umdjs/umd