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
The 'New' Keyword in JavaScript
Search
Chris Bateman
April 16, 2014
Programming
76
0
Share
The 'New' Keyword in JavaScript
Chris Bateman
April 16, 2014
More Decks by Chris Bateman
See All by Chris Bateman
Web Audio API + AngularJS
chrisbateman
1
840
Other Decks in Programming
See All in Programming
Swiftのレキシカルスコープ管理
kntkymt
0
210
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
420
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
310
[KCD Czech] eBPF Meets the GPU: Future of AI Infra Observability
doniacld
0
130
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
0
130
OSもどきOS
arkw
0
380
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.2k
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
110
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
210
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
330
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.5k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.4k
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
Testing 201, or: Great Expectations
jmmastey
46
8.2k
RailsConf 2023
tenderlove
30
1.5k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
Paper Plane
katiecoart
PRO
1
51k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Marketing to machines
jonoalderson
1
5.3k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
Transcript
None
None
None
None
var simpleObject = { a: 'a' }; { a: 'a'
} simpleObject.toString(); // um, where does this function come from?
None
var simpleObject = { a: 'a' }; { a: 'a',
__proto__: { ... toString: function, hasOwnProperty: function, ... } }
var Demo = function() { ... }; Demo.prototype.doSomething = function()
{ ... };
var Demo = function() { this.prop = 'text'; }; Demo.prototype.action
= function() { alert(this.prop); }; var myDemo = Demo(); myDemo; // undefined myDemo.action() // ERROR window.prop; // 'text'
var Demo = function() { this.prop = 'text'; }; Demo.prototype.action
= function() { alert(this.prop); }; var myDemo = Demo(); myDemo; // { prop:'a', action:function } window.prop; // undefined myDemo.action(); // alerts "text"
var Demo = function() { this.prop = 'text'; }; Demo.prototype.action
= function() { alert(this.prop); }; var myDemo = new Demo();
var Demo = function() { this.prop = 'text'; }; Demo.prototype.action
= function() { alert(this.prop); }; var myDemo = new Demo();
• • • • • • • •
Object.create(myProtoObject); var obj = Object.create(null); // returns { } obj.toString();
// ERROR
var Demo = function() { this.prop = 'text'; }; Demo.prototype.action
= function() { alert(this.prop); }; var myDemo = new Demo(); var Demo = { init: function() { this.prop = 'text'; }, action: function() { alert(this.prop); } }; var myDemo = Object.create(Demo); myDemo.init();
None