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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
210
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.2k
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
160
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
200
レガシー共有バッチ基盤への挑戦 - SREドリブンなリアーキテクチャリングの取り組み
tatsukoni
0
210
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
200
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
340
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
4.9k
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
5
760
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
150
なぜ今、コスト最適化(倹約)が必要なのか? ~AWSでのコスト最適化の進め方「目的編」~
htan
1
110
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
106
230k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Exploring anti-patterns in Rails
aemeredith
2
250
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Fireside Chat
paigeccino
41
3.8k
How to build a perfect <img>
jonoalderson
1
4.9k
Visualization
eitanlees
150
17k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Balancing Empowerment & Direction
lara
5
880
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
The Curse of the Amulet
leimatthew05
1
8.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
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