Your SlideShare is downloading. ×
0
ECMAScript 5: Новое в JavaScript Юрій Чайковський [email_address]
Syntax <ul><li>Reserved   words   </li></ul><ul><li>var  label = { </li></ul><ul><ul><li>class : &quot; active &quot; </li...
Arrays <ul><li>Iterations  </li></ul><ul><li>forEach(), every(), some(), map(), filter(), reduce(), reduceRight(),  </li><...
JSON <ul><li>var  event = { title : &quot; HTML5Camp  &quot;, date  : new Date(&quot; 2011-03-28T10:00:00.000Z &quot;),  }...
Strict mode <ul><li>&quot;use strict&quot;; </li></ul><ul><li>location = &quot; http://www.microsoft.com &quot;; </li></ul...
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 ,{ ( ...
Objects: New Point function  Point(x, y) {   return   Object.freeze ({   x: +x,   y: +y   }); } // (new Point(3,4)  instan...
Objects: New Point function  Point(x, y) {   return   Object.freeze ({   x: +x,   y: +y   }); } // (new Point(3,4)  instan...
Objects: Accessor (getter/setter)  Old school... var  evnt = ( function (){ var  eventType = &quot; barcamp &quot;; return...
Objects: Creating Object.create( p ,{ ( n : attrs )* })      .defineProperty( o , n , attrs )   .defineProperties( o ,{ ( ...
Objects: Accessor (getter/setter)  Brand new... var  evnt = { eventType : &quot;barcamp&quot;, get  type(){ //getter... re...
Objects: Accessor (getter/setter)  or... var  evnt = Object.defineProperties({},   {  'typeName' : { value : &quot;barcamp...
Objects:  Restrictions   <ul><li>Object.preventExtensions( obj ) Object.isExtensible( obj ) </li></ul><ul><li>Object.seal(...
References <ul><li>Mark Miller http://www.youtube.com/watch?v=Kq4FpMe6cRs </li></ul><ul><li>Douglas Crockford http://www.s...
Upcoming SlideShare
Loading in...5
×

ECMAScript 5: Новое в JavaScript

1,363

Published on

Presentation from HTML5 Camp, UXnext for designers, developers and UX professionals

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,363
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "ECMAScript 5: Новое в JavaScript"

  1. 1. ECMAScript 5: Новое в JavaScript Юрій Чайковський [email_address]
  2. 2. Syntax <ul><li>Reserved words </li></ul><ul><li>var label = { </li></ul><ul><ul><li>class : &quot; active &quot; </li></ul></ul><ul><li>} </li></ul><ul><li>Comma </li></ul><ul><li>var fibonacci = [0, 1, 2, 3, 5, ]; </li></ul><ul><li>Line breaks </li></ul><ul><li>var literal = &quot;Line breaks </li></ul><ul><ul><ul><ul><ul><li>is standardized&quot;; </li></ul></ul></ul></ul></ul>
  3. 3. Arrays <ul><li>Iterations </li></ul><ul><li>forEach(), every(), some(), map(), filter(), reduce(), reduceRight(), </li></ul><ul><li>Search indexOf(), lastIndexOf() </li></ul><ul><li>Type check fibonacci.isArray() === true ; </li></ul>
  4. 4. JSON <ul><li>var event = { title : &quot; HTML5Camp &quot;, date : new Date(&quot; 2011-03-28T10:00:00.000Z &quot;), } </li></ul><ul><li>JSON.stringify(value, replacer, space) </li></ul><ul><li>var str = JSON.stringify(event) ; {&quot;title&quot;:&quot;HTML5Camp&quot;,&quot;date&quot;:&quot;2011-03-28T10:00:00.000Z&quot;} </li></ul><ul><li>JSON.parse(string, reviver) JSON.parse(str, function(key, value){ if (key == &quot;title&quot;){ return value.trim(); } }); </li></ul>
  5. 5. Strict mode <ul><li>&quot;use strict&quot;; </li></ul><ul><li>location = &quot; http://www.microsoft.com &quot;; </li></ul><ul><li>var person = {&quot;name&quot; : &quot;Yura&quot;, &quot;name&quot; : &quot;Chaikovsky&quot;}; </li></ul><ul><li>var geval = eval; </li></ul><ul><li>with, arguments.caller, arguments.callee </li></ul><ul><li>( function (){...}).call( null ); ( function (){ return !this; })(); </li></ul><ul><li>Function.prototype.bind(thisArg, arg1, arg2....) </li></ul>
  6. 6. Objects: Point function Point(x, y) {   this .x = +x; this .y = +y; } var pt = new Point(3,5); pt.x = 'foo';
  7. 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. 8. Objects: New Point function Point(x, y) { return Object.freeze ({ x: +x, y: +y }); } // (new Point(3,4) instanceof Point) === false
  9. 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. 10. Objects: Accessor (getter/setter) Old school... var evnt = ( function (){ var eventType = &quot; barcamp &quot;; return { type : function (tp){ if (typeof tp != &quot; undefined &quot;){ //setter... eventType = tp; }else{ //getter... return eventType; } } }; })();
  11. 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. 12. Objects: Accessor (getter/setter) Brand new... var evnt = { eventType : &quot;barcamp&quot;, get type(){ //getter... return evnt.eventType; }, set type(tp){ //setter... evnt.eventType = tp; } };
  13. 13. Objects: Accessor (getter/setter) or... var evnt = Object.defineProperties({}, { 'typeName' : { value : &quot;barcamp&quot;, }, 'type' : { get : function() { return …; }, set : function(tp) { … }, } });
  14. 14. Objects: Restrictions <ul><li>Object.preventExtensions( obj ) Object.isExtensible( obj ) </li></ul><ul><li>Object.seal( obj ) Object.isSealed( obj ) </li></ul><ul><li>Object.freeze( obj ) Object.isFrozen( obj ) </li></ul>
  15. 15. References <ul><li>Mark Miller http://www.youtube.com/watch?v=Kq4FpMe6cRs </li></ul><ul><li>Douglas Crockford http://www.slideshare.net/douglascrockford/newandimproved </li></ul><ul><li>Ilia Kantor http://www.youtube.com/watch?v=082iuEKV72c </li></ul><ul><li>John Resig http://ejohn.org/blog/ecmascript-5-objects-and-properties/ http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ </li></ul><ul><li>David Flanagan http://davidflanagan.com/Talks/es5/slides.html </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×