Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hyper Private Variables in Javascript
Search
Ben Green
May 16, 2013
Technology
0
45
Hyper Private Variables in Javascript
Or, a merry romp through the fields of "why are javascript objects kinda weird"?
Ben Green
May 16, 2013
Tweet
Share
More Decks by Ben Green
See All by Ben Green
Lessons Learned with Grunt and Jasmine
veganben
0
62
Other Decks in Technology
See All in Technology
Context Engineeringの取り組み
nutslove
0
280
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
5
760
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.1k
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
1
270
Webhook best practices for rock solid and resilient deployments
glaforge
1
260
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
590
MCPでつなぐElasticsearchとLLM - 深夜の障害対応を楽にしたい / Bridging Elasticsearch and LLMs with MCP
sashimimochi
0
140
Databricks Free Edition講座 データサイエンス編
taka_aki
0
290
GitLab Duo Agent Platform × AGENTS.md で実現するSpec-Driven Development / GitLab Duo Agent Platform × AGENTS.md
n11sh1
0
120
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
1.6k
入社1ヶ月でデータパイプライン講座を作った話
waiwai2111
1
250
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.1k
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
1.9k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Building AI with AI
inesmontani
PRO
1
680
The Curious Case for Waylosing
cassininazir
0
230
Embracing the Ebb and Flow
colly
88
5k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.6k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
420
Utilizing Notion as your number one productivity tool
mfonobong
2
210
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
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