SlideShare a Scribd company logo
1 of 15
ECMAScript 5: Новое в JavaScript Юрій Чайковський [email_address]
Syntax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Arrays ,[object Object],[object Object],[object Object],[object Object]
JSON ,[object Object],[object Object],[object Object],[object Object]
Strict mode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Objects: Point function  Point(x, y) {   this .x = +x;    this .y = +y;  } var  pt =  new  Point(3,5); pt.x = 'foo';
Objects: Creating Object.create( p ,{ ( n : attrs )* })      .defineProperty( o , n , attrs )   .defineProperties( o ,{ ( n : attrs )* })   .getOwnPropertyNames( o )  ->   names   .getOwnPropertyDescriptor( o , n )  ->   attrs attrs  ::= {  value: v ,    writable: b ,         enumerable: b ,    configurable: b   } |   { get: f()->v ,  set: f(v) ,       enumerable: b ,   configurable: b  }
Objects: New Point function  Point(x, y) {   return   Object.freeze ({   x: +x,   y: +y   }); } // (new Point(3,4)  instanceof  Point) === false
Objects: New Point function  Point(x, y) {   return   Object.freeze ({   x: +x,   y: +y   }); } // (new Point(3,4)  instanceof  Point) === false function  Point(x, y) {   return  Object.freeze(   Object.create (Point.prototype, {   x: { value: +x, enumerable: true },   y: { value: +y, enumerable: true }   })); }
Objects: Accessor (getter/setter)  Old school... var  evnt = ( function (){ var  eventType = " barcamp "; return  { type :  function (tp){ if (typeof tp != " undefined "){ //setter... eventType = tp; }else{ //getter... return  eventType; } } }; })();
Objects: Creating Object.create( p ,{ ( n : attrs )* })      .defineProperty( o , n , attrs )   .defineProperties( o ,{ ( n : attrs )* })   .getOwnPropertyNames( o )  ->   names   .getOwnPropertyDescriptor( o , n )  ->   attrs attrs  ::= { value: v ,    writable: b ,         enumerable: b ,    configurable: b  } |   {  get: f()->v ,  set: f(v) ,       enumerable: b ,   configurable: b   }
Objects: Accessor (getter/setter)  Brand new... var  evnt = { eventType : "barcamp", get  type(){ //getter... return  evnt.eventType; }, set  type(tp){ //setter... evnt.eventType = tp; } };
Objects: Accessor (getter/setter)  or... var  evnt = Object.defineProperties({},   {  'typeName' : { value : "barcamp",  },   'type' : {   get : function() { return …; },   set : function(tp) { … },  } });
Objects:  Restrictions   ,[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot (20)

Un dsl pour ma base de données
Un dsl pour ma base de donnéesUn dsl pour ma base de données
Un dsl pour ma base de données
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
gd
gdgd
gd
 
Typelevel summit
Typelevel summitTypelevel summit
Typelevel summit
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Finch + Finagle OAuth2
Finch + Finagle OAuth2Finch + Finagle OAuth2
Finch + Finagle OAuth2
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
 
20151224-games
20151224-games20151224-games
20151224-games
 
Herding types with Scala macros
Herding types with Scala macrosHerding types with Scala macros
Herding types with Scala macros
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
F(2)
F(2)F(2)
F(2)
 
ts
tsts
ts
 
サイ本 文
サイ本 文サイ本 文
サイ本 文
 
A Shiny Example-- R
A Shiny Example-- RA Shiny Example-- R
A Shiny Example-- R
 
Ray Tracing with ZIO
Ray Tracing with ZIORay Tracing with ZIO
Ray Tracing with ZIO
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Reactive x
Reactive xReactive x
Reactive x
 
Sol10
Sol10Sol10
Sol10
 
Ray tracing with ZIO-ZLayer
Ray tracing with ZIO-ZLayerRay tracing with ZIO-ZLayer
Ray tracing with ZIO-ZLayer
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 

Similar to ECMAScript 5: Новое в JavaScript

Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montageKris Kowal
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!Brendan Eich
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basicsmsemenistyi
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leetjohndaviddalton
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationJoni
 
ITT 2015 - Saul Mora - Object Oriented Function Programming
ITT 2015 - Saul Mora - Object Oriented Function ProgrammingITT 2015 - Saul Mora - Object Oriented Function Programming
ITT 2015 - Saul Mora - Object Oriented Function ProgrammingIstanbul Tech Talks
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptIngvar Stepanyan
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs偉格 高
 
Object-oriented Javascript
Object-oriented JavascriptObject-oriented Javascript
Object-oriented JavascriptDaniel Ku
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery PresentationSony Jain
 

Similar to ECMAScript 5: Новое в JavaScript (20)

Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
OO in JavaScript
OO in JavaScriptOO in JavaScript
OO in JavaScript
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leet
 
Php sql-android
Php sql-androidPhp sql-android
Php sql-android
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
ITT 2015 - Saul Mora - Object Oriented Function Programming
ITT 2015 - Saul Mora - Object Oriented Function ProgrammingITT 2015 - Saul Mora - Object Oriented Function Programming
ITT 2015 - Saul Mora - Object Oriented Function Programming
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
AST - the only true tool for building JavaScript
AST - the only true tool for building JavaScriptAST - the only true tool for building JavaScript
AST - the only true tool for building JavaScript
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
Object-oriented Javascript
Object-oriented JavascriptObject-oriented Javascript
Object-oriented Javascript
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 

More from Департамент Стратегических Технологий

More from Департамент Стратегических Технологий (20)

Microsoft SWIT 2012 in Kyiv, Ukraine
Microsoft SWIT 2012 in Kyiv, UkraineMicrosoft SWIT 2012 in Kyiv, Ukraine
Microsoft SWIT 2012 in Kyiv, Ukraine
 
JavaScript как объектно-ориентированный язык программирования
JavaScript как объектно-ориентированный язык программированияJavaScript как объектно-ориентированный язык программирования
JavaScript как объектно-ориентированный язык программирования
 
HTML for smart TV
HTML for smart TVHTML for smart TV
HTML for smart TV
 
Semantic Grid. Layout of the future
Semantic Grid. Layout of the futureSemantic Grid. Layout of the future
Semantic Grid. Layout of the future
 
Progressive Enhancement
Progressive EnhancementProgressive Enhancement
Progressive Enhancement
 
Hard Rock Design
Hard Rock DesignHard Rock Design
Hard Rock Design
 
Способы структурирования данных и виды навигации сложных сайтов СМИ
Способы структурирования данных и виды навигации сложных сайтов СМИСпособы структурирования данных и виды навигации сложных сайтов СМИ
Способы структурирования данных и виды навигации сложных сайтов СМИ
 
CSS3 Animations
CSS3 AnimationsCSS3 Animations
CSS3 Animations
 
Responsive Web design. Что это и как использовать
Responsive Web design. Что это и как использоватьResponsive Web design. Что это и как использовать
Responsive Web design. Что это и как использовать
 
Инфографика
ИнфографикаИнфографика
Инфографика
 
Проектирование Интерфейсов
Проектирование ИнтерфейсовПроектирование Интерфейсов
Проектирование Интерфейсов
 
Разработка SaaS решений на платформе Windows Azure, Azure University
Разработка SaaS решений на платформе Windows Azure, Azure UniversityРазработка SaaS решений на платформе Windows Azure, Azure University
Разработка SaaS решений на платформе Windows Azure, Azure University
 
Архитектура облачных приложений. Типовые шаблоны, Azure University
Архитектура облачных приложений. Типовые шаблоны, Azure UniversityАрхитектура облачных приложений. Типовые шаблоны, Azure University
Архитектура облачных приложений. Типовые шаблоны, Azure University
 
Технический обзор платформы Windows Azure. Демонстрация, Azure University
Технический обзор платформы Windows Azure. Демонстрация, Azure UniversityТехнический обзор платформы Windows Azure. Демонстрация, Azure University
Технический обзор платформы Windows Azure. Демонстрация, Azure University
 
Сценарии применения Windows Azure, Azure University
Сценарии применения Windows Azure, Azure UniversityСценарии применения Windows Azure, Azure University
Сценарии применения Windows Azure, Azure University
 
Облачные сервисы Майкрософт и возможности для партнеров, Azure University
Облачные сервисы Майкрософт и возможности для партнеров, Azure UniversityОблачные сервисы Майкрософт и возможности для партнеров, Azure University
Облачные сервисы Майкрософт и возможности для партнеров, Azure University
 
Что нового в CSS3
Что нового в CSS3Что нового в CSS3
Что нового в CSS3
 
Обзор IE9 developer tools
Обзор IE9 developer toolsОбзор IE9 developer tools
Обзор IE9 developer tools
 
Pinned Sites
Pinned SitesPinned Sites
Pinned Sites
 
Карта Потребностей
Карта ПотребностейКарта Потребностей
Карта Потребностей
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL 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 RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

ECMAScript 5: Новое в JavaScript

  • 1. ECMAScript 5: Новое в JavaScript Юрій Чайковський [email_address]
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Objects: Point function Point(x, y) {   this .x = +x; this .y = +y; } var pt = new Point(3,5); pt.x = 'foo';
  • 7. Objects: Creating Object.create( p ,{ ( n : attrs )* })   .defineProperty( o , n , attrs ) .defineProperties( o ,{ ( n : attrs )* }) .getOwnPropertyNames( o ) -> names .getOwnPropertyDescriptor( o , n ) -> attrs attrs ::= { value: v , writable: b ,       enumerable: b , configurable: b } | { get: f()->v , set: f(v) ,      enumerable: b , configurable: b }
  • 8. Objects: New Point function Point(x, y) { return Object.freeze ({ x: +x, y: +y }); } // (new Point(3,4) instanceof Point) === false
  • 9. Objects: New Point function Point(x, y) { return Object.freeze ({ x: +x, y: +y }); } // (new Point(3,4) instanceof Point) === false function Point(x, y) { return Object.freeze( Object.create (Point.prototype, { x: { value: +x, enumerable: true }, y: { value: +y, enumerable: true } })); }
  • 10. Objects: Accessor (getter/setter) Old school... var evnt = ( function (){ var eventType = " barcamp "; return { type : function (tp){ if (typeof tp != " undefined "){ //setter... eventType = tp; }else{ //getter... return eventType; } } }; })();
  • 11. Objects: Creating Object.create( p ,{ ( n : attrs )* })   .defineProperty( o , n , attrs ) .defineProperties( o ,{ ( n : attrs )* }) .getOwnPropertyNames( o ) -> names .getOwnPropertyDescriptor( o , n ) -> attrs attrs ::= { value: v , writable: b ,       enumerable: b , configurable: b } | { get: f()->v , set: f(v) ,      enumerable: b , configurable: b }
  • 12. Objects: Accessor (getter/setter) Brand new... var evnt = { eventType : "barcamp", get type(){ //getter... return evnt.eventType; }, set type(tp){ //setter... evnt.eventType = tp; } };
  • 13. Objects: Accessor (getter/setter) or... var evnt = Object.defineProperties({}, { 'typeName' : { value : "barcamp", }, 'type' : { get : function() { return …; }, set : function(tp) { … }, } });
  • 14.
  • 15.