Soumettre la recherche
Mettre en ligne
EcmaScript 5.1
•
Télécharger en tant que PPTX, PDF
•
1 j'aime
•
589 vues
I
iliakan
Suivre
Technologie
Signaler
Partager
Signaler
Partager
1 sur 40
Télécharger maintenant
Recommandé
Es51
Es51
iliakan
实时用户体验收集
实时用户体验收集
Yan Wang
Gallery%203 {Courtney}
Gallery%203 {Courtney}
lilgreenbb
Portafolio Da4 14 09 2009 EDSON MARROQUIN
Portafolio Da4 14 09 2009 EDSON MARROQUIN
Edson Marroquin
Clearwire Company And Technology Overview
Clearwire Company And Technology Overview
larromac
Die Vrou
Die Vrou
estiesteenkamp
Four Flippin Boxes - 9 12 12
Four Flippin Boxes - 9 12 12
mboardma
Spain V Miguel Hernandez
Spain V Miguel Hernandez
Elliott Serbian
Recommandé
Es51
Es51
iliakan
实时用户体验收集
实时用户体验收集
Yan Wang
Gallery%203 {Courtney}
Gallery%203 {Courtney}
lilgreenbb
Portafolio Da4 14 09 2009 EDSON MARROQUIN
Portafolio Da4 14 09 2009 EDSON MARROQUIN
Edson Marroquin
Clearwire Company And Technology Overview
Clearwire Company And Technology Overview
larromac
Die Vrou
Die Vrou
estiesteenkamp
Four Flippin Boxes - 9 12 12
Four Flippin Boxes - 9 12 12
mboardma
Spain V Miguel Hernandez
Spain V Miguel Hernandez
Elliott Serbian
P101 B04
P101 B04
jingger
Greg Crowsnest
Greg Crowsnest
gregross
Influenza diego
Influenza diego
gueste432f3
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
PRN USM
Wisdom Circles Presentation09
Wisdom Circles Presentation09
Mary-Ann Mitchell-Pellett
Edmedia 2014
Edmedia 2014
Gjoa Andrichuk
Celebrating Mexicans
Celebrating Mexicans
guest0392e01
Ny State Lote Check Point B Exam, Yuqing Hong
Ny State Lote Check Point B Exam, Yuqing Hong
Project for Developing Chinese Language Teachers
Lit 1 Worksheet
Lit 1 Worksheet
lilgreenbb
Pedagogia vocal
Pedagogia vocal
Fundación Portafolio Cultural
a
a
guest83eb548f
Erwartung
Erwartung
torioreo
Writing J27
Writing J27
guest61dc4ad
Academic Writing
Academic Writing
guest61dc4ad
Kv
Kv
kevinkv2
Kloet Onderhoud - Bedrijfsprofiel
Kloet Onderhoud - Bedrijfsprofiel
chris_oerlemans
Biggest Fan Contest Entry
Biggest Fan Contest Entry
orthoassociates
RSS
RSS
Levadia Library
Contenu connexe
En vedette
P101 B04
P101 B04
jingger
Greg Crowsnest
Greg Crowsnest
gregross
Influenza diego
Influenza diego
gueste432f3
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
PRN USM
Wisdom Circles Presentation09
Wisdom Circles Presentation09
Mary-Ann Mitchell-Pellett
Edmedia 2014
Edmedia 2014
Gjoa Andrichuk
Celebrating Mexicans
Celebrating Mexicans
guest0392e01
Ny State Lote Check Point B Exam, Yuqing Hong
Ny State Lote Check Point B Exam, Yuqing Hong
Project for Developing Chinese Language Teachers
Lit 1 Worksheet
Lit 1 Worksheet
lilgreenbb
Pedagogia vocal
Pedagogia vocal
Fundación Portafolio Cultural
a
a
guest83eb548f
Erwartung
Erwartung
torioreo
Writing J27
Writing J27
guest61dc4ad
Academic Writing
Academic Writing
guest61dc4ad
Kv
Kv
kevinkv2
Kloet Onderhoud - Bedrijfsprofiel
Kloet Onderhoud - Bedrijfsprofiel
chris_oerlemans
Biggest Fan Contest Entry
Biggest Fan Contest Entry
orthoassociates
RSS
RSS
Levadia Library
En vedette
(18)
P101 B04
P101 B04
Greg Crowsnest
Greg Crowsnest
Influenza diego
Influenza diego
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
Prevalence And Factors Associated With Smoking Among Students And Staff In Upm
Wisdom Circles Presentation09
Wisdom Circles Presentation09
Edmedia 2014
Edmedia 2014
Celebrating Mexicans
Celebrating Mexicans
Ny State Lote Check Point B Exam, Yuqing Hong
Ny State Lote Check Point B Exam, Yuqing Hong
Lit 1 Worksheet
Lit 1 Worksheet
Pedagogia vocal
Pedagogia vocal
a
a
Erwartung
Erwartung
Writing J27
Writing J27
Academic Writing
Academic Writing
Kv
Kv
Kloet Onderhoud - Bedrijfsprofiel
Kloet Onderhoud - Bedrijfsprofiel
Biggest Fan Contest Entry
Biggest Fan Contest Entry
RSS
RSS
EcmaScript 5.1
1.
EcmaScript5.1 MASTERING NAMESPACES!
Илья Кантор http://javascript.ru
2.
История
3.
varuser=<username="John"> <fieldtype="age"value="25"/> <fieldtype="email"value="john@gmail.com"/>
</user> alert(user.field.(@type=="email").@value) 1997 ECMA-262 1st edition 1999 ECMA-2623rd edition 2001 Compact Profile 2004 E4X — ECMA-262 4th ed. 2009 ECMA-2625th edition ??? — ECMA-262Harmony
4.
ECMA-2625th edition
Что нового?
5.
ECMA-2625th edition
Багфиксы
6.
obj={ class:'Menu' }
ES3: ошибка ES5: ok
7.
functiontest(str){ varre=/ok/g alert(re.test(str))
} test("ok") test("ok") // true // ES3: false, ES5: true
8.
alert(parseInt("010")==parseFloat("010")) ES3: false
ES5: true
9.
varobj={ a:1, b:2,
} vararr[1,2,3,] ES3: error ES5: ok
10.
МетаСвойства
11.
writable = false
obj={ class:'Menu' } obj.class='Bird‘ =>obj.class == ‘Menu’
12.
configurable = false
obj={ class:'Menu' } deleteobj.class =>obj.class == ‘Menu’
13.
enumerable = false
Object.prototype.each=... for(propin{}){ // без свойства ‘each’ }
14.
Объявление Object.defineProperty({},"class", {
value:"Menu", writable:false, configurable:false, enumerable:true }) => { “class” : “Menu” } property descriptor
15.
Объявление Object.defineProperties({},{ class:{
value:"Menu", writable:false, configurable:false }, height:{ value:200, configurable:false } }) => { “class” : “Menu”, “height”: 200 }
16.
Закрытие объекта varuser={
name:"Вася", /* ... */ } Object.preventExtensions(user) user.a=5// Нельзя добавлять свойства Object.seal(user) deleteuser.name// Нельзя удалять свойства Object.freeze(user) user.name='Петя'// Нельзя менять свойства
17.
Наследование animal={ canWalk:true
} rabbit=Object.create(animal,{ canRun:{ value:true } }) alert(rabbit.canWalk)// true Object.getPrototypeOf(rabbit) == animal // true
18.
Наследование rabbit=Object.create(animal,{ canRun:{
value:true } }) bird=Object.create(Object.getPrototypeOf(rabbit),{ canFly:{ value:true } })
19.
Геттеры и Сеттеры
user=Object.defineProperty({},"fullName",{ get:function(){ returnthis.firstName+' '+this.lastName }, set:function(value){ vars=value.trim().split(/+/,2) this.firstName=s[0]; this.lastName=s[1] } }) user.fullName="Вася Пупкин" alert(user.lastName)// Пупкин
20.
Геттеры и Сеттеры
varuser={ getfullName(){ returnthis.firstName+' '+this.lastName }, setfullName(value){ vars=value.trim().split(/+/,2) this.firstName=s[0]; this.lastName=s[1] } } user.fullName="Вася Пупкин" alert(user.lastName)// Пупкин
21.
JSON
22.
23.
JSON – любые
объекты functionRoom(number){ this.toJSON=function(){ returnnumber } } event={ title:"Conference", date:newDate(), room:newRoom(22) } JSON.stringify(event) {"title":"Conference","date":"2011-02-15T09:12:06.836Z","room":22}
24.
JSON – любые
объекты functionRoom(number){ this.toJSON=function(){ returnnumber } } event={ title:"Conference", date:newDate(), Date.prototype.toJSON room:newRoom(22) } JSON.stringify(event) {"title":"Conference","date":"2011-02-15T09:12:06.836Z","room":22}
25.
JSON.stringify(str, whitelist) event={
title:"Conference", date:newDate(), domElement:document.body } JSON.stringify(event) => TypeError: Converting circular structure to JSON JSON.stringify(event,["title","date"]) => {"title":"Conference","date":"2011-02-15T09:44:13.419Z"}
26.
JSON.stringify(str, replacer) event={
title:"Conference", date:newDate(), domElement:document.body } JSON.stringify(event,function(key,value){ returnvalue.nodeName?undefined:value }) => {"title":"Conference","date":"2011-02-15T09:44:13.419Z"}
27.
JSON.parse(str) str='{"title":"Conference",
br /> "date":"2011-02-15T09:44:13.419Z"}' event=JSON.parse(str) пробелы
28.
JSON.parse(str) str='{"title":"Conference",
br /> "date":"2011-02-15T09:44:13.419Z"}' event=JSON.parse(str) event.date.getDay() => TypeError: no method 'getDay'
29.
JSON.parse(str, reviver) str='{"title":"Conference",
br /> "date":"2011-02-15T09:44:13.419Z"}' event=JSON.parse(str,function(key,value){ if(key=='date'){ returnnewDate(value) } returnvalue }) event.date.getDay() => 2
30.
bind
31.
bind(this) functionButton(elem){ this.sayHi=function(){
alert('Hi') } elem.onclick=function(){ this.sayHi() }.bind(this) }
32.
bind(this, args) functionButton(elem){
this.say=function(phrase){ alert(phrase) } elem.onclick=function(event,phrase){ this.say(phrase) }.bind(this,'Hi') } @see http://www.prototypejs.org/api/function/bind
33.
Strict mode
34.
use strict "use
strict" ... code ...
35.
use strict functionF(){
"use strict" this.method=function(){ // strict mode inherited } }
36.
use strict alert(010)//
SyntaxError (octal literals deprecated) a=5// ReferenceError (undeclared a) obj.notWritable=...// TypeError deleteobj.notConfigurable// TypeError eval("var a = 5") alert(a)// ReferenceError (undeclared a) arguments.callee// TypeError arguments.caller// TypeError (function(){ alert(this)// undefined вместо window })() with(..)// SyntaxError, 'with' statement
37.
Функции,которые давно ждали
Object.keys(obj) "String".trim() Array.isArray(arr) [...].indexOf/lastIndexOf [...].forEach [...].map [...].filter [...].reduce/reduceRight // ... @seehttp://kangax.github.com/es5-compat-table/
38.
The future is
now ? PrototypeJS ES5-shim
39.
Harmony
40.
It’s all real
__noSuchMethod__Proxy.create letblock_scoped="yay!" constREALLY="srsly" #(x) { x * x } ifx>zreturn"без скобок" moduleIter="@std:Iteration" return[i*iforiinrange(n)] functionprintf(format,...args)ek_scoped= "yay!" consEALLY= "srsly"
Télécharger maintenant