Outils pour utilisateurs

Outils du site


informatique:javascript:tests_de_compatibilite

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:javascript:tests_de_compatibilite [04/05/2018 20:34] – [Is javascript works ?] cyrilleinformatique:javascript:tests_de_compatibilite [05/05/2018 19:17] (Version actuelle) cyrille
Ligne 1: Ligne 1:
  
 ====== Is javascript works ? ====== ====== Is javascript works ? ======
 +
 +Should be write 'OK' :
  
 <html> <html>
Ligne 8: Ligne 10:
 </html> </html>
  
-If it's not writed OK, no javascript available.+====== toLocaleDateString() ======
  
-====== Object.assign() ======+<html> 
 +<script> 
 +var d '04/05/2018'; 
 +document.write('<b>date string: ' + d +'</b><br/>')
 +new Date(Date.parse(d)); 
 +document.write('<b>fr: ' + d.toLocaleDateString('fr') +'</b><br/>'); 
 +document.write('<b>en: ' + d.toLocaleDateString('en') +'</b>'); 
 +</script> 
 +</html>
  
-===== Assign simple with scalar properties =====+===== Workaround =====
  
 <html> <html>
 <script> <script>
-var o1 { a:1 }; +function date_as_slug( date ) 
-var o2 Object.assigno1, { b:2 } );+
 + var y = date.getFullYear(), 
 + = 1+date.getMonth(), 
 + d = date.getDate(), 
 + h = date.getHours(), 
 + mn = date.getMinutes(); 
 + return y + (m<10?'0'+m:m) + (d<10?'0'+d:d) + '-' + (h<10?'0'+h:h) + (mn<10?'0'+mn:mn) ; 
 +} 
 + 
 +document.write( '<b>' + date_as_slug(new Date()) +'</b><br/>' ); 
 + 
 +var date '04/05/2018'; 
 +d = new Date(Date.parse(date)); 
 +document.write('<b>' + date +' => '+ d +' => '+ date_as_slug( d ) +'</b><br/>'); 
 + 
 +date = '2018-05-04'; 
 +d = new Date(Date.parse(date)); 
 +document.write('<b>' + date +' => '+ d +' => '+ date_as_slug( d ) +'</b><br/>');
  
-document.write( '<b>' + o2.a +','+ o2.b + '</b>' ); 
 </script> </script>
 </html> </html>
  
-===== Assign simple with complex properties =====+====== Object copy ====== 
 + 
 +===== Object.assign() - only scalar properties ===== 
 + 
 +Should be write 1,2 :
  
 <html> <html>
 <script> <script>
-var o1 = { a:1 }; +try { 
-var o2 = Object.assign( o1, { b:function(){ return 2;} );+ var o1 = { a:1 }; 
 + var o2 = Object.assign( o1, { b:2 } ); 
 + document.write'<b>' + o2.a +','+ o2.b + '</b>' ); 
 +catch ( e ){ 
 + document.write( '<p>ERROR: ' + e.message + '</p>' ); 
 +
 +</script> 
 +</html>
  
-document.write( '<b>' + o2.a +','+ o2.b() + '</b>' );+===== Object.assign() - complex properties ===== 
 + 
 +Should be write 1,2 : 
 + 
 +<html> 
 +<script> 
 +try { 
 + var o1 = { a:1 }; 
 + var o2 = Object.assign( o1, { b:function(){ return 2;} } ); 
 + document.write( '<b>' + o2.a +','+ o2.b() + '</b>' ); 
 +} catch ( e ){ 
 + document.write( '<p>ERROR: ' + e.message + '</p>' ); 
 +}
 </script> </script>
 </html> </html>
 +
 +===== Object.create() - complex properties =====
 +
 +Should be write 1,2 :
 +
 +<html>
 +<script>
 +try {
 + var o1 = { a:1, b:function(){ return 2;} };
 + var o2 = Object.create( o1 );
 + document.write( '<b>' + o2.a +','+ o2.b() + '</b>' );
 +} catch ( e ){
 + document.write( '<p>ERROR: ' + e.message + '</p>' );
 +}
 +</script>
 +</html>
 +
 +
 +
  
informatique/javascript/tests_de_compatibilite.1525458881.txt.gz · Dernière modification : 04/05/2018 20:34 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki