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
Hyper Private Variables in Javascript
Search
Ben Green
May 16, 2013
Technology
49
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Hyper Private Variables in Javascript
Or, a merry romp through the fields of "why are javascript objects kinda weird"?
Ben Green
May 16, 2013
More Decks by Ben Green
See All by Ben Green
Lessons Learned with Grunt and Jasmine
veganben
0
65
Other Decks in Technology
See All in Technology
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
870
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
170
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
340
AI コーディングと人間の認知スループット / CTO Night & Day 2026 Morning Session / AI Coding and Human Cognitive Throughput
prog893
4
1k
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
250
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
450
hackers_champloo_2026_tidb
makocchi
0
160
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
Local CI × GitHub Actions
gogutan
2
190
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
990
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
490
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
HDC tutorial
michielstock
2
960
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Bash Introduction
62gerente
615
220k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Un-Boring Meetings
codingconduct
0
460
Designing Experiences People Love
moore
143
24k
Exploring anti-patterns in Rails
aemeredith
4
540
Transcript
Hyper-Private Variables in JavaScript @veganben
None
Netscape Naviagtor Asynchronous Prototype based Influenced by C, Self, Scheme
An evolving langauge TC 39 JS Lint & JSON Coffee
Script
Patterns
Objects
Getting Started:
Array.prototype.last = function(){ return this[this.length-1] } var theEnd = [1,2,3,4,5].last();
>> 5
Object.defineProperty(Array.prototype, 'last', { enumerable: false, configurable: true, get: function() {
return this[this.length - 1]; }, set: undefined });
Constructor: function Message(param) { this.greeting = param; } Instantiation: var
helloMessage = new Message('hello');
prototype inheritance: Message.prototype.greet = function (who) { return this.greeting +
" " + who; } method invocation: var greeting = helloMessage.greet("world"); >> “hello world” function Message(param) { this.greeting = param; } var sayHello = new Message('hello');
Public and Private:
function Message(param) { var greetedCount = 0; this.greeeting = param;
}
function Message(param) { var greetedCount = 0; this.incrementGreeted = function(){
greetedCount++; } this.greeeting = param; }
var myModule = (function () { var privateStuff; var publicStuff;
return { visible: publicStuff }
function Counter() { var increment, decrement, get; (function() { var
privateCount = 0; increment = function() { return count++ }; decrement = function() { return count--; }; get = function() { return privateCount; }; })(); this.set = function(param) { if(param >=0 ){ increment(); } else { decrement } }; this.getCount = function() { return get(); } }
var filmCount = new Count(); filmCount.set(1); filmCount.getCount();
for example