Advertisement
ARIELCARRARO

prograJS01.html

May 25th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2.  <html lang="es">
  3.  <head>
  4.   <meta charset="utf-8">
  5.   <title>::Programando en HTML5 & Javascript::</title>
  6. </head>
  7. <body>
  8. <header><h1>Programando en HTML5 & Javascript</h1></header>
  9. <section id="contenedor">
  10.  
  11. <article>
  12.     <h2>Uso de hashmap</h2>
  13.  
  14. <script type="text/javascript">
  15. function activaHash(){
  16.     var nombres={
  17.         spiderman: "Peter",
  18.         superman: "Clark",
  19.         capitan_america: "Steve",
  20.         batman: "Bruce"
  21.     }
  22.     var acu="";
  23.     for(n in nombres){
  24.         acu+="\n[alias: "+n +" ,nombre: "+nombres[n]+"]\n";
  25.     }
  26.     document.writeln(acu);
  27.     console.log(acu);
  28.  
  29.  
  30.     console.log(nombres["spiderman"]);// obtendremos Peter
  31.     console.log(nombres["batman"]);// obtendremos Bruce
  32.  
  33.     nombres["spawn"]="Al Simmons";
  34.     console.log(nombres)
  35.  
  36.     var nombreABuscar="David";
  37.     console.log(nombreABuscar in nombres); // nos devolverá false
  38.     console.log("spawn" in nombres); //nos devolverá true
  39.     console.log(batman in nombres); //error
  40.  
  41. }
  42. activaHash();
  43.  
  44.  
  45.  
  46.  
  47. </script>
  48. </article>
  49. <aside>::::</aside>
  50. <article>ejemplo de hashmap</article>
  51. </section>
  52. <footer>@yo</footer>
  53. </body>
  54. </hml>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement