Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript">
- //01. Assign all the possible JavaScript literals to different variables.
- //Boolean
- var _false = (false === 0);
- console.log(_false);
- //Integer
- var _integer = 1;
- console.log(_integer);
- //Floating-point
- var _floating = -3.14159265359;
- console.log(_floating);
- //String
- var _string = "The brown fox jumped over the lazy dog.";
- console.log(_string);
- //Object
- var _object = {
- phone: "LG",
- model: "OPTIMUS L7 II",
- fullname: function() {
- return this.phone + " " + this.model;
- }
- };
- console.log(_object.fullname());
- //Array
- var _array = ["Lamborghini", "Renault", "Dacia"];
- console.log(_array[1]);
- console.log(_array.toString());
- //Function
- var _function = function() {
- return "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
- };
- console.log(_function);
- //02. Create a string variable with quoted text in it.
- var _quotes = "\"How you doin'?\", Joey said.";
- console.log(_quotes);
- //03. Try typeof on all variables you created.
- console.log(typeof _false);
- console.log(typeof _integer);
- console.log(typeof _floating);
- console.log(typeof _string);
- console.log(typeof _object);
- console.log(typeof _array);
- console.log(typeof _function);
- //04. Create null, undefined variables and try typeof on them.
- var _null = null;
- var _undefined = undefined;
- console.log(_null + " " + _undefined);
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement