informatique:javascript:tests_de_compatibilite
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
informatique:javascript:tests_de_compatibilite [04/05/2018 20:42] – cyrille | informatique:javascript:tests_de_compatibilite [05/05/2018 19:17] (Version actuelle) – cyrille | ||
---|---|---|---|
Ligne 18: | Ligne 18: | ||
d = new Date(Date.parse(d)); | d = new Date(Date.parse(d)); | ||
document.write('< | document.write('< | ||
- | document.write('< | + | document.write('< |
</ | </ | ||
</ | </ | ||
- | ====== Object.assign() ====== | + | ===== Workaround |
- | ===== Assign simple with scalar properties ===== | + | < |
+ | < | ||
+ | function date_as_slug( date ) | ||
+ | { | ||
+ | var y = date.getFullYear(), | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | document.write( '< | ||
+ | |||
+ | var date = ' | ||
+ | d = new Date(Date.parse(date)); | ||
+ | document.write('< | ||
+ | |||
+ | date = ' | ||
+ | d = new Date(Date.parse(date)); | ||
+ | document.write('< | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Object copy ====== | ||
+ | |||
+ | ===== Object.assign() - only scalar properties ===== | ||
Should be write 1,2 : | Should be write 1,2 : | ||
Ligne 30: | Ligne 57: | ||
< | < | ||
< | < | ||
- | var o1 = { a:1 }; | + | try { |
- | var o2 = Object.assign( o1, { b:2 } ); | + | var o1 = { a:1 }; |
- | document.write( '< | + | var o2 = Object.assign( o1, { b:2 } ); |
+ | | ||
+ | } catch ( e ){ | ||
+ | | ||
+ | } | ||
</ | </ | ||
</ | </ | ||
- | ===== Assign simple with complex properties ===== | + | ===== Object.assign() - complex properties ===== |
Should be write 1,2 : | Should be write 1,2 : | ||
Ligne 42: | Ligne 73: | ||
< | < | ||
< | < | ||
- | var o1 = { a:1 }; | + | try { |
- | var o2 = Object.assign( o1, { b: | + | var o1 = { a:1 }; |
- | document.write( '< | + | var o2 = Object.assign( o1, { b: |
+ | | ||
+ | } catch ( e ){ | ||
+ | | ||
+ | } | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ===== Object.create() - complex properties ===== | ||
+ | |||
+ | Should be write 1,2 : | ||
+ | |||
+ | < | ||
+ | < | ||
+ | try { | ||
+ | var o1 = { a:1, b: | ||
+ | var o2 = Object.create( o1 ); | ||
+ | | ||
+ | } catch ( e ){ | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
informatique/javascript/tests_de_compatibilite.1525459324.txt.gz · Dernière modification : 04/05/2018 20:42 de cyrille