Advertisement
fabi0

Untitled

May 11th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <script type="text/javascript">
  5.             //01. Assign all the possible JavaScript literals to different variables.
  6.  
  7.  
  8.             //Boolean
  9.             var _false = (false === 0);
  10.             console.log(_false);
  11.  
  12.             //Integer
  13.             var _integer = 1;
  14.             console.log(_integer);
  15.  
  16.             //Floating-point
  17.             var _floating = -3.14159265359;
  18.             console.log(_floating);
  19.  
  20.             //String
  21.             var _string = "The brown fox jumped over the lazy dog.";
  22.             console.log(_string);
  23.  
  24.             //Object
  25.             var _object = {
  26.                 phone: "LG",
  27.                 model: "OPTIMUS L7 II",
  28.                 fullname: function() {
  29.                     return this.phone + " " + this.model;
  30.                 }
  31.             };
  32.             console.log(_object.fullname());
  33.  
  34.             //Array
  35.             var _array = ["Lamborghini", "Renault", "Dacia"];
  36.             console.log(_array[1]);
  37.             console.log(_array.toString());
  38.  
  39.             //Function
  40.             var _function = function() {
  41.                 return "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
  42.             };
  43.             console.log(_function);
  44.  
  45.             //02. Create a string variable with quoted text in it.
  46.  
  47.  
  48.             var _quotes = "\"How you doin'?\", Joey said.";
  49.             console.log(_quotes);
  50.  
  51.  
  52.             //03. Try typeof on all variables you created.
  53.  
  54.  
  55.             console.log(typeof _false);
  56.             console.log(typeof _integer);
  57.             console.log(typeof _floating);
  58.             console.log(typeof _string);
  59.             console.log(typeof _object);
  60.             console.log(typeof _array);
  61.             console.log(typeof _function);
  62.  
  63.  
  64.             //04. Create null, undefined variables and try typeof on them.
  65.  
  66.  
  67.             var _null = null;
  68.             var _undefined = undefined;
  69.             console.log(_null + " " + _undefined);
  70.         </script>
  71.     </head>
  72.     <body>
  73.  
  74.     </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement