Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- /*Data types
- *
- *There are simple and complex data types.
- *
- *Simple data types do not hold, collect, or aggregate other values.
- *
- *Numbers are numeric data.
- *Strings are character data.
- *Booleans are binary data, represented as true or false.
- *NaN is not a number. When operations are performed on undefined variables,
- * we get this falsey data type.
- *Undefined means that a variable has been declared, but has not been given
- * a value.
- *Null means no value. The old value has been nullified by a programmer.
- *Infinity represents mathematical infinity.
- *
- * Operators on primitives return new primitives: */
- var numberFive = 5;
- console.log(numberFive + 6);
- /*Complex data types are objects, arrays, and functions. Objects can
- * contain any number of key:value pairs. Arrays can contain any number of
- * elements. Functions can encapsulate any number of statements. */
- // Objects
- var myObject = {
- key1: "value1",
- key2: "value2",
- key3: "value3"
- }
- // Objects can be modified elsewhere in code.
- myObject.key4 = "value4";
- console.log(myObject);
- // Arrays are zero-indexed lists of data types.
- var myArray = ["value1", "value2", "value3"];
- // Arrays can also be modified elsewhere in code.
- myArray.push("value4");
- console.log(myArray);
- // Functions are reusable blocks of code which perform operations when invoked.
- function myFunction(a, b) {
- console.log(a + " " + b);
- }
- // Invocations
- var firstName = "Mario";
- var lastName = "the Plumber";
- myFunction(firstName, lastName);
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/*Data types
- *
- *There are simple and complex data types.
- *
- *Simple data types do not hold, collect, or aggregate other values.
- *
- *Numbers are numeric data.
- *Strings are character data.
- *Booleans are binary data, represented as true or false.
- *NaN is not a number. When operations are performed on undefined variables,
- * we get this falsey data type.
- *Undefined means that a variable has been declared, but has not been given
- * a value.
- *Null means no value. The old value has been nullified by a programmer.
- *Infinity represents mathematical infinity.
- *
- * Operators on primitives return new primitives: */
- var numberFive = 5;
- console.log(numberFive + 6);
- /*Complex data types are objects, arrays, and functions. Objects can
- * contain any number of key:value pairs. Arrays can contain any number of
- * elements. Functions can encapsulate any number of statements. */
- // Objects
- var myObject = {
- key1: "value1",
- key2: "value2",
- key3: "value3"
- }
- // Objects can be modified elsewhere in code.
- myObject.key4 = "value4";
- console.log(myObject);
- // Arrays are zero-indexed lists of data types.
- var myArray = ["value1", "value2", "value3"];
- // Arrays can also be modified elsewhere in code.
- myArray.push("value4");
- console.log(myArray);
- // Functions are reusable blocks of code which perform operations when invoked.
- function myFunction(a, b) {
- console.log(a + " " + b);
- }
- // Invocations
- var firstName = "Mario";
- var lastName = "the Plumber";
- myFunction(firstName, lastName);
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement