Soumettre la recherche
Mettre en ligne
OOP in JavaScript
•
16 j'aime
•
5,974 vues
Eyal Vardi
Suivre
OOP in JavaScript
Lire moins
Lire la suite
Technologie
Business
Affichage du diaporama
Signaler
Partager
Affichage du diaporama
Signaler
Partager
1 sur 45
Recommandé
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
Forms in AngularJS
Forms in AngularJS
Eyal Vardi
Backbone testing
Backbone testing
Crashlytics
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
Yuya Takeyama
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015
Konstantin Kudryashov
Building Robust jQuery Plugins
Building Robust jQuery Plugins
Jörn Zaefferer
Mocking Demystified
Mocking Demystified
Marcello Duarte
Taming Command Bus
Taming Command Bus
Krzysztof Menżyk
Recommandé
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
Forms in AngularJS
Forms in AngularJS
Eyal Vardi
Backbone testing
Backbone testing
Crashlytics
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
Yuya Takeyama
Min-Maxing Software Costs - Laracon EU 2015
Min-Maxing Software Costs - Laracon EU 2015
Konstantin Kudryashov
Building Robust jQuery Plugins
Building Robust jQuery Plugins
Jörn Zaefferer
Mocking Demystified
Mocking Demystified
Marcello Duarte
Taming Command Bus
Taming Command Bus
Krzysztof Menżyk
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Krzysztof Menżyk
Be pragmatic, be SOLID
Be pragmatic, be SOLID
Krzysztof Menżyk
PhpSpec 2.0 ilustrated by examples
PhpSpec 2.0 ilustrated by examples
Marcello Duarte
購物車程式架構簡介
購物車程式架構簡介
Jace Ju
Min-Maxing Software Costs
Min-Maxing Software Costs
Konstantin Kudryashov
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014
Guillaume POTIER
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
Intro to Angular.JS Directives
Intro to Angular.JS Directives
Christian Lilley
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
Guy Royse
Functional Structures in PHP
Functional Structures in PHP
Marcello Duarte
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Baldur Rensch
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
Angular Directives from Scratch
Angular Directives from Scratch
Christian Lilley
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
Mark
AngularJS Animations
AngularJS Animations
Eyal Vardi
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Kacper Gunia
Advanced php testing in action
Advanced php testing in action
Jace Ju
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
Asp.net mvc internals & extensibility
Asp.net mvc internals & extensibility
Eyal Vardi
AngularJS $Provide Service
AngularJS $Provide Service
Eyal Vardi
AngularJS Routing
AngularJS Routing
Eyal Vardi
AngularJS - $http & $resource Services
AngularJS - $http & $resource Services
Eyal Vardi
Contenu connexe
Tendances
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Krzysztof Menżyk
Be pragmatic, be SOLID
Be pragmatic, be SOLID
Krzysztof Menżyk
PhpSpec 2.0 ilustrated by examples
PhpSpec 2.0 ilustrated by examples
Marcello Duarte
購物車程式架構簡介
購物車程式架構簡介
Jace Ju
Min-Maxing Software Costs
Min-Maxing Software Costs
Konstantin Kudryashov
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014
Guillaume POTIER
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
Intro to Angular.JS Directives
Intro to Angular.JS Directives
Christian Lilley
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
Guy Royse
Functional Structures in PHP
Functional Structures in PHP
Marcello Duarte
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Baldur Rensch
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
Angular Directives from Scratch
Angular Directives from Scratch
Christian Lilley
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
Mark
AngularJS Animations
AngularJS Animations
Eyal Vardi
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Kacper Gunia
Advanced php testing in action
Advanced php testing in action
Jace Ju
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Kacper Gunia
Asp.net mvc internals & extensibility
Asp.net mvc internals & extensibility
Eyal Vardi
AngularJS $Provide Service
AngularJS $Provide Service
Eyal Vardi
Tendances
(20)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID (at Boiling Frogs, Wrocław)
Be pragmatic, be SOLID
Be pragmatic, be SOLID
PhpSpec 2.0 ilustrated by examples
PhpSpec 2.0 ilustrated by examples
購物車程式架構簡介
購物車程式架構簡介
Min-Maxing Software Costs
Min-Maxing Software Costs
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Intro to Angular.JS Directives
Intro to Angular.JS Directives
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
Functional Structures in PHP
Functional Structures in PHP
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2
Angular Directives from Scratch
Angular Directives from Scratch
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
AngularJS Animations
AngularJS Animations
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Advanced php testing in action
Advanced php testing in action
PHPSpec - the only Design Tool you need - 4Developers
PHPSpec - the only Design Tool you need - 4Developers
Asp.net mvc internals & extensibility
Asp.net mvc internals & extensibility
AngularJS $Provide Service
AngularJS $Provide Service
En vedette
AngularJS Routing
AngularJS Routing
Eyal Vardi
AngularJS - $http & $resource Services
AngularJS - $http & $resource Services
Eyal Vardi
AngularJS Compile Process
AngularJS Compile Process
Eyal Vardi
AngulrJS Overview
AngulrJS Overview
Eyal Vardi
AngularJS Testing
AngularJS Testing
Eyal Vardi
AngularJS Directives
AngularJS Directives
Eyal Vardi
AngularJS Architecture
AngularJS Architecture
Eyal Vardi
En vedette
(7)
AngularJS Routing
AngularJS Routing
AngularJS - $http & $resource Services
AngularJS - $http & $resource Services
AngularJS Compile Process
AngularJS Compile Process
AngulrJS Overview
AngulrJS Overview
AngularJS Testing
AngularJS Testing
AngularJS Directives
AngularJS Directives
AngularJS Architecture
AngularJS Architecture
Similaire à OOP in JavaScript
Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
Eyal Vardi
What’s new in ECMAScript 6.0
What’s new in ECMAScript 6.0
Eyal Vardi
AMD & Require.js
AMD & Require.js
Eyal Vardi
Node.js Event Emitter
Node.js Event Emitter
Eyal Vardi
Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
Eyal Vardi
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
Js hacks
Js hacks
Nishchit Dhanani
Say It With Javascript
Say It With Javascript
Giovanni Scerra ☃
JSDay Italy - Backbone.js
JSDay Italy - Backbone.js
Pierre Spring
JavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
JSGeneve - Backbone.js
JSGeneve - Backbone.js
Pierre Spring
Triggers, actions & behaviors in XAML
Triggers, actions & behaviors in XAML
Eyal Vardi
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
So you think you know JavaScript
So you think you know JavaScript
Matt Apperson
Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0
Eyal Vardi
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
johndaviddalton
Future of JavaScript
Future of JavaScript
Eyal Vardi
Stuff you didn't know about action script
Stuff you didn't know about action script
Christophe Herreman
Javascript tid-bits
Javascript tid-bits
David Atchley
Similaire à OOP in JavaScript
(20)
Objects & Classes in ECMAScript 6.0
Objects & Classes in ECMAScript 6.0
What’s new in ECMAScript 6.0
What’s new in ECMAScript 6.0
AMD & Require.js
AMD & Require.js
Node.js Event Emitter
Node.js Event Emitter
Iterators & Generators in ECMAScript 6.0
Iterators & Generators in ECMAScript 6.0
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Js hacks
Js hacks
Say It With Javascript
Say It With Javascript
JSDay Italy - Backbone.js
JSDay Italy - Backbone.js
JavaScript for PHP developers
JavaScript for PHP developers
JSGeneve - Backbone.js
JSGeneve - Backbone.js
Triggers, actions & behaviors in XAML
Triggers, actions & behaviors in XAML
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
So you think you know JavaScript
So you think you know JavaScript
Proxies in ECMAScript 6.0
Proxies in ECMAScript 6.0
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
Future of JavaScript
Future of JavaScript
Stuff you didn't know about action script
Stuff you didn't know about action script
Javascript tid-bits
Javascript tid-bits
Plus de Eyal Vardi
Why magic
Why magic
Eyal Vardi
Smart Contract
Smart Contract
Eyal Vardi
Rachel's grandmother's recipes
Rachel's grandmother's recipes
Eyal Vardi
Performance Optimization In Angular 2
Performance Optimization In Angular 2
Eyal Vardi
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Eyal Vardi
Angular 2 NgModule
Angular 2 NgModule
Eyal Vardi
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
Eyal Vardi
Routing And Navigation
Routing And Navigation
Eyal Vardi
Angular 2 Architecture
Angular 2 Architecture
Eyal Vardi
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
Eyal Vardi
Angular 2.0 Views
Angular 2.0 Views
Eyal Vardi
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
Http Communication in Angular 2.0
Http Communication in Angular 2.0
Eyal Vardi
Angular 2.0 Dependency injection
Angular 2.0 Dependency injection
Eyal Vardi
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
Angular 2.0 Pipes
Angular 2.0 Pipes
Eyal Vardi
Angular 2.0 forms
Angular 2.0 forms
Eyal Vardi
Modules and injector
Modules and injector
Eyal Vardi
Plus de Eyal Vardi
(20)
Why magic
Why magic
Smart Contract
Smart Contract
Rachel's grandmother's recipes
Rachel's grandmother's recipes
Performance Optimization In Angular 2
Performance Optimization In Angular 2
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 NgModule
Angular 2 NgModule
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
Routing And Navigation
Routing And Navigation
Angular 2 Architecture
Angular 2 Architecture
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
Angular 2.0 Views
Angular 2.0 Views
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Template syntax in Angular 2.0
Template syntax in Angular 2.0
Http Communication in Angular 2.0
Http Communication in Angular 2.0
Angular 2.0 Dependency injection
Angular 2.0 Dependency injection
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Angular 2.0 Pipes
Angular 2.0 Pipes
Angular 2.0 forms
Angular 2.0 forms
Modules and injector
Modules and injector
Dernier
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Safe Software
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Sinan KOZAK
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Pooja Nehwal
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
soniya singh
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
Sujit Pal
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Malak Abu Hammad
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
OnBoard
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
Slack Application Development 101 Slides
Slack Application Development 101 Slides
praypatel2
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
shyamraj55
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
gurkirankumar98700
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Paola De la Torre
Dernier
(20)
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Slack Application Development 101 Slides
Slack Application Development 101 Slides
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
OOP in JavaScript
1.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
2.
http://www.expertdays.co.il © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
3.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
4.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
5.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
6.
var person =
{ name: "Nicholas" }; var person = {}; Object.defineProperty( person, "name", { configurable: true, enumerable: false, writable: false, value: "Michal" }); alert(person.name); //Michal person.name = "Eyal"; alert(person.name); //Michal © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
7.
var person =
{}; Object.defineProperty(person, "name", { configurable: false, value: "Michal" }); // Throws an error Object.defineProperty(person, "name", { configurable: true, value: "Michal" }); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
8.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
9.
var book =
{ _year: 2004, edition: 1 }; Object.defineProperty(book, "year", { get: function(){ return this._year; }, set: function(newValue){ if (newValue > 2004) { this._year = newValue; } } }); book.year = 2005; © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il __defineGetter__() and __defineSetter__() old version Prior to the ECMAScript 5.
10.
var book =
{}; Object.defineProperties(book, { // Data Properties _year: { value: 2004 }, edition: { value: 1 }, // Accessor Properties year: { get: function () { return this._year; }, set: function (newValue) { if (newValue > 2004) { this._year = newValue; this.edition += newValue - 2004; } } } }); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
11.
var descriptor =
Object.getOwnPropertyDescriptor(book, "_year"); alert(descriptor.value); //2004 alert(descriptor.configurable); //false alert(typeof descriptor.get); //”undefi ned” var descriptor = Object.getOwnPropertyDescriptor(book, "year"); alert(descriptor.value); //undefined alert(descriptor.enumerable); //false alert(typeof descriptor.get); //”function” © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
12.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
13.
// makes it
impossible to add properties to obj. Example: var obj = { foo: 'a' }; Object.preventExtensions(obj); obj.bar = 'b'; // fails silently alert(obj.bar); // undefined // You can still delete properties, though. delete obj.foo; alert(obj.foo); // undefined // Checks whether obj is extensible: Object.isExtensible(obj); // false © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
14.
var obj =
{ foo: 'a' }; Object.getOwnPropertyDescriptor(obj, 'foo'); // before sealing // { value: 'a', writable: true, enumerable: true, configurable: true } Object.seal(obj); Object.getOwnPropertyDescriptor(obj, 'foo'); // after sealing // { value: 'a', writable: true, enumerable: true, configurable: false } // You can still change the property foo: obj.foo = 'b'; Object.isSealed(obj); // true © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
15.
var point =
{ x: 17, y: -5 }; Object.freeze(point); point.x = 2; // no effect, point.x is read-only //Checking whether an object is frozen Object.isFrozen(obj); // true © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
16.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
17.
function Person(name, age,
job) { this.name = name; this.age = age; this.job = job; this.sayName = function () { alert(this.name); }; } var person1 = new Person("Dan", 29, "Software Engineer"); var person2 = new Person("Greg", 27, "Doctor"); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
18.
alert(person1.constructor == Person);
//true alert(person2.constructor == Person); //true © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
19.
//use as a
constructor var person = new Person("Dan", 29, "Engineer"); person.sayName(); // "DaN" //call as a function Person("Greg", 27, "Doctor"); //adds to window window.sayName(); //"Greg" //call in the scope of another object var o = new Object(); Person.call(o, "Kristen", 25, "Nurse"); o.sayName(); //"Kristen" © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
20.
function var var this function this function var new © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
21.
function Person(name, age,
job) { ... this.sayName = function () { alert(this.name); }; //logical equivalent this.sayName = new Function("alert(this.name)"); } alert(person1.sayName == person2.sayName); //false © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
22.
function Person(name, age,
job) { this.name = name; this.age = age; this.job = job; this.sayName = sayName; } function sayName() { alert(this.name); } © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
23.
function Cat(name, age,
job){ this.name = name; this.age = age; this.friends = ['A', 'B']; } Cat.prototype.sayName = function () { return this.name; } var myCat = new Cat('Mizi', 29); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
24.
var friend =
new Person(); Person.prototype.sayHi = function(){ alert("hi"); }; friend.sayHi(); //"hi" - works! © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
25.
function Person(){ } var
friend = new Person(); // friend.__proto__ = Person.prototype Person.prototype constructor: name : age : job : sayName : }; = { Person, "Nicholas", 29, "Software Engineer", function () { alert(this.name); } friend.sayName(); // Error © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
26.
function Person(name, age,
job){ // properties this.name = name; this.age = age; this.job = job; // methods if (typeof this.sayName != "function"){ Person.prototype.sayName = function(){ alert(this.name); }; } } var friend = new Person('Nicholas', 29, 'Software Engineer'); friend.sayName(); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
27.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
28.
© 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
29.
SubType.prototype = SuperType.prototype function
SuperType() { this.val = true; } SuperType.prototype.getSuperValue = function () { return this.val; }; function SubType() { this.subVal = false; } //inherit from SuperType SubType.prototype = SuperType.prototype; val getSubValue subVal SubType.prototype.getSubValue = function () { return this.subVal; }; __proto__ var instance = new SubType(); // undefined ( this.val == undefined ) alert(instance.getSuperValue() ); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il getSuperValue subVal
30.
SubType.prototype = new
SuperType(); function SuperType() { this.val = true; } SuperType.prototype.getSuperValue = function () { return this.val; }; function SubType() { this.subVal = false; } SubType.prototype = new SuperType(); SubType.prototype.getSubValue = function () { // new method return this.subVal; }; SubType.prototype.getSuperValue = function () {// override method return false; }; var instance = new SubType(); alert(instance.getSuperValue()); //false © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
31.
SubType.prototype = new
SuperType(); [prototype] getSuperValue val [prototype] subVal __proto__ val __proto__ subVal © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
32.
function SuperType(){ this.colors =
['red', 'blue', 'green']; } function SubType(){ } SubType.prototype = new SuperType(); var instance1 = new SubType(); instance1.colors.push('black'); alert(instance1.colors); //"red,blue,green,black" var instance2 = new SubType(); alert(instance2.colors); //"red,blue,green,black" © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
33.
function SuperType(){ this.colors =
['red', 'blue', 'green']; } function SubType(){ //inherit from SuperType SuperType.call(this); } SubType.prototype = new SuperType(); var instance1 = new SubType(); instance1.colors.push("black"); alert(instance1.colors); //"red,blue,green,black" var instance2 = new SubType(); alert(instance2.colors); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il //"red,blue,green"
34.
function SuperType(name){ this.name =
name; } function SubType(){ //inherit from SuperType passing in an argument SuperType.call(this, "Nicholas"); //instance property this.age = 29; } SubType.prototype = new SuperType(); ... var instance = new SubType(); alert(instance.name); //"Nicholas"; alert(instance.age); //29 © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
35.
[prototype] getSuperValue val [prototype] subVal __proto__ val __proto__ val subVal © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
36.
function create(o) { function
F() { } F.prototype = o; new F() return new F(); } © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il __proto__ o
37.
var person =
{ name: "Eyal", friends: ["Ran", "Dan"] }; var anotherPerson = Object(person); anotherPerson.name = "Greg"; anotherPerson.friends.push("Rob"); // Object.create(person); var yetAnotherPerson = Object(person); yetAnotherPerson.name = "Linda"; yetAnotherPerson.friends.push("Van"); alert(person.friends); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il // "Ran, Dan, Rob, Van"
38.
function SuperType(name){ this.name =
name; this.colors = ['red', 'blue', 'green']; } SuperType.prototype.sayName = function(){ alert(this.name); }; function SubType(name, age){ SuperType.call(this, name); this.age = age; } SubType.prototype = Object.create(SuperType.prototype); SubType.prototype.sayAge = function(){ alert(this.age); }; © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
39.
[prototype] getSuperValue val [prototype] subVal __proto__ val subVal © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il __proto__
40.
function SuperType(name){ this.name =
name; this.colors = ['red', 'blue', 'green']; } SuperType.prototype.sayName = function(){ return this.name; }; function SubType(name, age){ SuperType.call(this, name); this.age = age; } SubType.prototype = Object.create(SuperType.prototype); SubType.prototype.constructor = SubType; fix constructor SubType.prototype.sayAge = function(){ alert(this.age); }; override SubType.prototype.sayName = function(){ return SuperType.prototype.sayName.call(this) + "!!"; }; © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
41.
alert( person instanceof
Object ); alert( colors instanceof Array ); alert( pattern instanceof RegExp ); © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
42.
var instance =
new SubType(); alert(instance instanceof Object); //true alert(instance instanceof SuperType); //true alert(instance instanceof SubType); //true alert(Object.prototype.isPrototypeOf(instance)); //true alert(SuperType.prototype.isPrototypeOf(instance)); //true alert(SubType.prototype.isPrototypeOf(instance)); //true © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
43.
var toString =
Object.prototype.toString; toString.call(new Date); toString.call(new String); toString.call(Math); // [object Date] // [object String] // [object Math] toString.call(undefined); toString.call(null); // [object Undefined] // [object Null] © 2013 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
44.
http://eyalvardi.wordpress.com/resources/html-5course-resourses/javascript/ http://javascript.info/tutorial © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
45.
eyalvardi.wordpress.com © 2013 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il