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
0
66
The 'New' Keyword in JavaScript
Chris Bateman
April 16, 2014
Tweet
Share
More Decks by Chris Bateman
See All by Chris Bateman
Web Audio API + AngularJS
chrisbateman
1
830
Other Decks in Programming
See All in Programming
Patterns of Patterns
denyspoltorak
0
1.4k
CSC307 Lecture 02
javiergs
PRO
1
780
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
Oxlint JS plugins
kazupon
1
900
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
CSC307 Lecture 01
javiergs
PRO
0
690
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
120
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
「ブロックテーマでは再現できない」は本当か?
inc2734
0
970
CSC307 Lecture 07
javiergs
PRO
0
550
Fluid Templating in TYPO3 14
s2b
0
130
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.9k
The SEO Collaboration Effect
kristinabergwall1
0
350
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
820
The Curious Case for Waylosing
cassininazir
0
230
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.1k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
65
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
710
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
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