From 7521d7186c0b2d0a8bae438fda89a8ab7235bb96 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 14:02:46 -0400 Subject: [PATCH 01/27] let reference simplified description first pass --- src/core/reference.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/reference.js b/src/core/reference.js index 9ecf9cd039..295b985383 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -5,7 +5,15 @@ */ /** + * Creates and names a new variable. A variable is a container for a value. + * Variables that are declared with "let` will have block-scope. + * This means that the variable only exists within the that it is created within. + * + * + * From the MDN entry: * Declares a block scope local variable, optionally initializing it to a value. + * * @property let * * @example From 50129b412a841e3981b4c900341abcce1d4efea8 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 14:08:33 -0400 Subject: [PATCH 02/27] const reference - first pass --- src/core/reference.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 295b985383..6ef9061cb6 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -6,7 +6,7 @@ /** * Creates and names a new variable. A variable is a container for a value. - * Variables that are declared with "let` will have block-scope. + * Variables that are declared with let will have block-scope. * This means that the variable only exists within the that it is created within. * @@ -28,6 +28,14 @@ */ /** + * Creates and names a new constant variable. A variable is a container for a value. + * Variables that are declared with const will have block-scope. + * This means that the variable only exists within the that it is created within. + * const is different from let in that + * variables declared with const cannot be reassigned or redeclared. + * + * From the MDN entry: * Declares a read-only named constant. * Constants are block-scoped, much like variables defined using the 'let' statement. * The value of a constant can't be changed through reassignment, and it can't be redeclared. @@ -36,9 +44,9 @@ * @example *
* - * //define MY_FAV as a constant and give it the value 7 - * const MY_FAV = 7; - * console.log('my favorite number is: ' + MY_FAV); + * // define myFavNumber as a constant and give it the value 7 + * const myFavNumber = 7; + * console.log('my favorite number is: ' + myFavNumber); * *
*/ From ab3dc71eb00f2d8d9e8dfeeb7f6860a9e5ea3ede Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 14:18:07 -0400 Subject: [PATCH 03/27] if-else reference simplification first pass --- src/core/reference.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/reference.js b/src/core/reference.js index 6ef9061cb6..b0b0469134 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -56,6 +56,14 @@ */ /** + * The if-else statement helps control the flow of your code. + * A condition is placed between the parenthesis following 'if'. + * When that condition evalues to < href="https://developer.mozilla.org/en-US/docs/Glossary/truthy">truthy, + * the code between the preceding curly braces is run. + * Alternatively, when the condition evaluates to falsy, + * the code between the curly braces that precedes 'else' is run instead. + * + * From the MDN entry: * The 'if' statement executes a statement if a specified condition is truthy. * If the condition is falsy, another statement can be executed * @property if-else From 4748c239d664c4cad3740c4c7b0c805ef4276f7d Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 14:27:16 -0400 Subject: [PATCH 04/27] function reference simplification first pass --- src/core/reference.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index b0b0469134..e75d25a477 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -86,16 +86,22 @@ */ /** + * Creates and names a function. + * A function is a set of statements that perform a task. + * Optionally, functions can have parameters. Parameters + * are variables that are scoped to the function, that can be assigned a value when calling the function. + * + * From the MDN entry: * Declares a function with the specified parameters. * @property function * * @example *
* - * function calRectArea(width, height) { + * function calculateRectArea(width, height) { * return width * height; * } - * calRectArea(4, 5); //calling the function + * calculateRectArea(4, 5); // calling the function * *
*/ @@ -107,10 +113,10 @@ * @example *
* - * function calSquare(x) { + * function calculateSquare(x) { * return x * x; * } - * calSquare(4); //return 16 + * calculateSquare(4); //return 16 * *
*/ From f58fbcf2a500a999983a46d35a5af780a28b839e Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 14:40:12 -0400 Subject: [PATCH 05/27] return first pass --- src/core/reference.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/reference.js b/src/core/reference.js index e75d25a477..8dc1032cc5 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -108,6 +108,8 @@ /** * Specifies the value to be returned by a function. + * For more info checkout + * the MDN entry for return. * @property return * * @example @@ -116,7 +118,7 @@ * function calculateSquare(x) { * return x * x; * } - * calculateSquare(4); //return 16 + * calculateSquare(4); // returns 16 * * */ From 41c7eac53c15430aed6b9bbf0b3fccb1b5998349 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 15:33:04 -0400 Subject: [PATCH 06/27] add types and simplify class --- src/core/reference.js | 97 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 8dc1032cc5..f05d96e046 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -124,25 +124,108 @@ */ /** - * @submodule Class + * @submodule Types */ /** - * The class declaration creates a new class with a given name using prototype-based inheritance. + * boolean is one of the 7 primitive data types in Javascript. + * A boolean can only be `true` or `false`. + * + * From the MDN entry: + * Boolean represents a logical entity and can have two values: true, and false. + * + * @property boolean + * + * @example + *
+ * + * const myBoolean = false; + * console.log(typeof myBoolean); // prints 'boolean' to the console + * + *
+ */ + +/** + * string is one of the 7 primitive data types in Javascript. + * A string is a series of text characters. In Javascript, a string value must be surrounded by either single-quotation marks(') or double-quotation marks("). + * + * From the MDN entry: + * A string is a sequence of characters used to represent text. + * + * @property string + * + * @example + *
+ * + * const mood = 'chill'; + * console.log(typeof mood); // prints 'string' to the console + * + *
+ */ + +/** + * number is one of the 7 primitive data types in Javascript. + * A number can be a whole number or a decimal number. + * + * The MDN entry for number + * + * @property number + * + * @example + *
+ * + * const num = 46.5; + * console.log(typeof num); // prints 'number' to the console + * + *
+ */ + +/** + * + * From MDN's object basics: + * An object is a collection of related data and/or functionality (which usually consists of several variables and functions — + * which are called properties and methods when they are inside objects.) + * @property object + * + * @example + *
+ * + * const author = { + * name: 'Ursula K Le Guin', + * books: [ + * 'The Left Hand of Darkness', + * 'The Dispossessed', + * 'A Wizard of Earthsea' + * ] + * }; + * console.log(author.name); // prints 'Ursula K Le Guin' to the console + * + *
+ */ + +/** + * @submodule Classes + */ + +/** + * A class is template for the creation of objects. + * + * From the MDN entry: + * The class declaration creates a new Class with a given name using prototype-based inheritance. * @property class * * @example *
* - * class S1 { - * constructor(height, width) { - * this.name = 'Polygon'; + * class Polygon { + * constructor(name, height, width) { + * this.name = name; * this.height = height; * this.width = width; * } * } - * const poly = new S1(4, 5); //creating new instance of Polygon Class. - * console.log(poly.name); + * const square = new Polygon('square', 1, 1); // creating new instance of Polygon Class. + * console.log(square.width); // prints '1' to the console * *
*/ From bebe13ee2e1bcc92cdb2d3a44b0deeb9067827da Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 15:45:19 -0400 Subject: [PATCH 07/27] for loop first pass --- src/core/reference.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/reference.js b/src/core/reference.js index f05d96e046..2fb5a21be9 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -235,6 +235,19 @@ */ /** + * for creates a loop that is useful for executing the code multiple times. + * + * A 'for loop' consists of three different expressions inside of a parenthesis, all of which are optional. + * These expressions are used to control the number of times the loop is run. + * The first expression is a statement that is used to set the initial state for the loop. + * The second expression is a condition that you would like to check before each loop. If this expression returns + * false then the loop will exit. + * The third expression is executed at the end of each loop. + * + * The code inside of the loop body (in between the curly braces) is executed between the evaluation of the second + * and third expression. + * + * From the MDN entry: * Creates a loop that executes a specified statement until the test condition evaluates to false. * The condition is evaluated after executing the statement, resulting in the specified statement executing at least once. * @property for @@ -244,7 +257,6 @@ * * for (let i = 0; i < 9; i++) { * console.log(i); - * // more statements * } * * From 9817e263a14b20883b314a59ea8ff010fdf503bd Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 15:50:22 -0400 Subject: [PATCH 08/27] for - in first pass --- src/core/reference.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/reference.js b/src/core/reference.js index 2fb5a21be9..a05a4312b8 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -263,6 +263,7 @@ */ /** + * From the MDN entry: * Iterates over the enumerable properties of an object, in arbitrary order. * For each distinct property, statements can be executed. * @property for-in From 68386bd0f1806a3befcfae1743fb56637a9074ec Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 15:53:31 -0400 Subject: [PATCH 09/27] for - of first pass --- src/core/reference.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/reference.js b/src/core/reference.js index a05a4312b8..ab1abb9e32 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -283,6 +283,7 @@ */ /** + * From the MDN entry: * Iterates over iterable objects (including arrays, array-like objects, iterators and generators), * invoking a custom iteration hook with statements to be executed for the value of each distinct property. * @property for-of @@ -291,7 +292,7 @@ *
* * const word = 'boo'; - * for (let value of word) { + * for (const value of word) { * console.log(value); * } * From b77b4927350269ee8b74f0d8d154ff74387bc84d Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 15:55:09 -0400 Subject: [PATCH 10/27] parseInt first pass --- src/core/reference.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/reference.js b/src/core/reference.js index ab1abb9e32..5f4574fae0 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -304,6 +304,7 @@ */ /** + * From the MDN entry: * The parseInt() function parses a string argument and * returns an integer of the specified radix (the base in mathematical numeral systems). * @method parseInt From 62849605667472e1c033f294b73fff9e0fac05ae Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 16:00:20 -0400 Subject: [PATCH 11/27] JSON.stringify first pass --- src/core/reference.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 5f4574fae0..c49f9cfa40 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -319,6 +319,7 @@ */ /** + * From the MDN entry: * The JSON.stringify() method converts a JavaScript object or value to a JSON string. * @method stringify * @for JSON @@ -327,9 +328,10 @@ * @example *
* - * JSON.stringify('foo'); // '"foo"' - * JSON.stringify([1, 'false', false]); //'[1,"false",false]' - * JSON.stringify([NaN, null, Infinity]); //'[null,null,null]' + * const myObject = { x: 5, y: 6 }; + * const myObjectAsString = JSON.stringify(myObject); + * console.log(myObjectAsString); // prints "{"x":5,"y":6}" to the console + * console.log(typeof myObjectAsString); // prints 'string' to the console * *
*/ From 335b62194005c4246a7c8eee93597c0303c4fa6a Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Fri, 4 Oct 2019 16:14:59 -0400 Subject: [PATCH 12/27] cleanup --- src/core/reference.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index c49f9cfa40..d72b884e2d 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -7,7 +7,7 @@ /** * Creates and names a new variable. A variable is a container for a value. * Variables that are declared with let will have block-scope. - * This means that the variable only exists within the * block that it is created within. * * @@ -30,7 +30,7 @@ /** * Creates and names a new constant variable. A variable is a container for a value. * Variables that are declared with const will have block-scope. - * This means that the variable only exists within the * block that it is created within. * const is different from let in that * variables declared with const cannot be reassigned or redeclared. @@ -58,7 +58,7 @@ /** * The if-else statement helps control the flow of your code. * A condition is placed between the parenthesis following 'if'. - * When that condition evalues to < href="https://developer.mozilla.org/en-US/docs/Glossary/truthy">truthy, + * When that condition evalues to truthy, * the code between the preceding curly braces is run. * Alternatively, when the condition evaluates to falsy, * the code between the curly braces that precedes 'else' is run instead. @@ -71,7 +71,7 @@ * @example *
* - * let a = 4; + * const a = 4; * if (a > 0) { * console.log('positive'); * } else { @@ -87,8 +87,8 @@ /** * Creates and names a function. - * A function is a set of statements that perform a task. - * Optionally, functions can have parameters. Parameters + * A function is a set of statements that perform a task. + * Optionally, functions can have parameters. Parameters * are variables that are scoped to the function, that can be assigned a value when calling the function. * * From the MDN entry: @@ -128,7 +128,7 @@ */ /** - * boolean is one of the 7 primitive data types in Javascript. + * A boolean is one of the 7 primitive data types in Javascript. * A boolean can only be `true` or `false`. * * From the MDN entry: @@ -146,7 +146,7 @@ */ /** - * string is one of the 7 primitive data types in Javascript. + * A string is one of the 7 primitive data types in Javascript. * A string is a series of text characters. In Javascript, a string value must be surrounded by either single-quotation marks(') or double-quotation marks("). * * From the MDN entry: @@ -164,7 +164,7 @@ */ /** - * number is one of the 7 primitive data types in Javascript. + * A number is one of the 7 primitive data types in Javascript. * A number can be a whole number or a decimal number. * * The MDN entry for number @@ -183,7 +183,7 @@ /** * * From MDN's object basics: - * An object is a collection of related data and/or functionality (which usually consists of several variables and functions — + * An object is a collection of related data and/or functionality (which usually consists of several variables and functions — * which are called properties and methods when they are inside objects.) * @property object * @@ -208,7 +208,7 @@ */ /** - * A class is template for the creation of objects. + * Creates and names a class which is a template for the creation of objects. * * From the MDN entry: * The class declaration creates a new Class with a given name using prototype-based inheritance. @@ -264,7 +264,7 @@ /** * From the MDN entry: - * Iterates over the enumerable properties of an object, in arbitrary order. + * Iterates over the enumerable properties of an object, in arbitrary order. * For each distinct property, statements can be executed. * @property for-in * @@ -305,7 +305,7 @@ /** * From the MDN entry: - * The parseInt() function parses a string argument and + * The parseInt() function parses a string argument and * returns an integer of the specified radix (the base in mathematical numeral systems). * @method parseInt * @@ -320,7 +320,7 @@ /** * From the MDN entry: - * The JSON.stringify() method converts a JavaScript object or value to a JSON string. + * The JSON.stringify() method converts a JavaScript object or value to a JSON string. * @method stringify * @for JSON * @param {Object} object :Javascript object that you would like to convert to JSON From d032c2de8474eb1cbd7d0d29c4b6949d0d24233c Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 09:39:37 -0400 Subject: [PATCH 13/27] Change all const outside of const reference to let --- src/core/reference.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index d72b884e2d..eccb778df3 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -71,7 +71,7 @@ * @example *
* - * const a = 4; + * let a = 4; * if (a > 0) { * console.log('positive'); * } else { @@ -139,7 +139,7 @@ * @example *
* - * const myBoolean = false; + * let myBoolean = false; * console.log(typeof myBoolean); // prints 'boolean' to the console * *
@@ -157,7 +157,7 @@ * @example *
* - * const mood = 'chill'; + * let mood = 'chill'; * console.log(typeof mood); // prints 'string' to the console * *
@@ -174,7 +174,7 @@ * @example *
* - * const num = 46.5; + * let num = 46.5; * console.log(typeof num); // prints 'number' to the console * *
@@ -190,7 +190,7 @@ * @example *
* - * const author = { + * let author = { * name: 'Ursula K Le Guin', * books: [ * 'The Left Hand of Darkness', @@ -224,7 +224,7 @@ * this.width = width; * } * } - * const square = new Polygon('square', 1, 1); // creating new instance of Polygon Class. + * let square = new Polygon('square', 1, 1); // creating new instance of Polygon Class. * console.log(square.width); // prints '1' to the console * *
@@ -271,7 +271,7 @@ * @example *
* - * const person = { fname: 'John', lname: 'Doe', age: 25 }; + * let person = { fname: 'John', lname: 'Doe', age: 25 }; * let text = ''; * let x; * for (x in person) { @@ -291,8 +291,8 @@ * @example *
* - * const word = 'boo'; - * for (const value of word) { + * let word = 'boo'; + * for (let value of word) { * console.log(value); * } * @@ -328,8 +328,8 @@ * @example *
* - * const myObject = { x: 5, y: 6 }; - * const myObjectAsString = JSON.stringify(myObject); + * let myObject = { x: 5, y: 6 }; + * let myObjectAsString = JSON.stringify(myObject); * console.log(myObjectAsString); // prints "{"x":5,"y":6}" to the console * console.log(typeof myObjectAsString); // prints 'string' to the console * From a85742120ea43759c387d66bde62cc0d39b5895a Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 09:43:13 -0400 Subject: [PATCH 14/27] Remove for-in and for-of --- src/core/reference.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index eccb778df3..4a6f795328 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -262,43 +262,6 @@ *
*/ -/** - * From the MDN entry: - * Iterates over the enumerable properties of an object, in arbitrary order. - * For each distinct property, statements can be executed. - * @property for-in - * - * @example - *
- * - * let person = { fname: 'John', lname: 'Doe', age: 25 }; - * let text = ''; - * let x; - * for (x in person) { - * text += person[x] + ''; - * } - * console.log(text); //'John Doe 25 ' - * - *
- */ - -/** - * From the MDN entry: - * Iterates over iterable objects (including arrays, array-like objects, iterators and generators), - * invoking a custom iteration hook with statements to be executed for the value of each distinct property. - * @property for-of - * - * @example - *
- * - * let word = 'boo'; - * for (let value of word) { - * console.log(value); - * } - * - *
- */ - /** * @submodule JS Method */ From f38ba358285892860ccee923c31d625fc6921135 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 09:44:43 -0400 Subject: [PATCH 15/27] Remove parseInt reference --- src/core/reference.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 4a6f795328..217d74d7a1 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -266,21 +266,6 @@ * @submodule JS Method */ -/** - * From the MDN entry: - * The parseInt() function parses a string argument and - * returns an integer of the specified radix (the base in mathematical numeral systems). - * @method parseInt - * - * @example - *
- * - * parseInt('F', 16); - * parseInt(21, 8); - * - *
- */ - /** * From the MDN entry: * The JSON.stringify() method converts a JavaScript object or value to a JSON string. From 64fb3e2e864727d3a03528cdf46350c2b03a46c8 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 09:48:26 -0400 Subject: [PATCH 16/27] fix const links and a little more internal reference linking --- src/core/reference.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 217d74d7a1..e9337b1b11 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -32,8 +32,8 @@ * Variables that are declared with const will have block-scope. * This means that the variable only exists within the * block that it is created within. - * const is different from let in that - * variables declared with const cannot be reassigned or redeclared. + * const is different from let in that + * variables declared with const cannot be reassigned or redeclared. * * From the MDN entry: * Declares a read-only named constant. @@ -56,7 +56,7 @@ */ /** - * The if-else statement helps control the flow of your code. + * The if-else statement helps control the flow of your code. * A condition is placed between the parenthesis following 'if'. * When that condition evalues to truthy, * the code between the preceding curly braces is run. From ff03f51b244b3e6701e6ea9b0efb30fd59810ed8 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 09:51:44 -0400 Subject: [PATCH 17/27] Fix misuse of word 'precede' --- src/core/reference.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index e9337b1b11..2ee0e81f82 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -59,9 +59,9 @@ * The if-else statement helps control the flow of your code. * A condition is placed between the parenthesis following 'if'. * When that condition evalues to truthy, - * the code between the preceding curly braces is run. + * the code between the following curly braces is run. * Alternatively, when the condition evaluates to falsy, - * the code between the curly braces that precedes 'else' is run instead. + * the code between the curly braces that follow 'else' is run instead. * * From the MDN entry: * The 'if' statement executes a statement if a specified condition is truthy. From f8dda775acf25b05093e7c1d76a8b11c66ab81fc Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 6 Oct 2019 10:04:09 -0400 Subject: [PATCH 18/27] Avoid odd term 'constant variable' --- src/core/reference.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 2ee0e81f82..27cd14fe7f 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -28,12 +28,13 @@ */ /** - * Creates and names a new constant variable. A variable is a container for a value. - * Variables that are declared with const will have block-scope. - * This means that the variable only exists within the - * block that it is created within. - * const is different from let in that - * variables declared with const cannot be reassigned or redeclared. + * Creates and names a new constant. Like a variable created with let, a constant + * that is created with const is a container for a value, + * however constants cannot be changed once they are declared. + * Constants have block-scope. This means that the constant only exists within + * the + * block that it is created within. A constant cannot be redeclared within a scope in which it + * already exists. * * From the MDN entry: * Declares a read-only named constant. From 1a33a344128d51cc3142c6d7ffa012bc8870764e Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Mon, 7 Oct 2019 11:28:03 -0400 Subject: [PATCH 19/27] Add console.log reference --- src/core/reference.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/core/reference.js b/src/core/reference.js index 27cd14fe7f..6e3fa396d6 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -284,3 +284,30 @@ *
*
*/ + +/** + * Prints a message to your browser's web console. When using p5, you can use print + * and console.log interchangeably. + * + * The console is opened differently depending on which browser you are using. + * Here are links on how to open the console in Firefox + * , Chrome, Edge, + * and Safari. With the online p5 editor the + * console is embedded directly in the page underneath the code editor. + * + * From the MDN entry: + * The Console method log() outputs a message to the web console. The message may be a single string (with optional substitution values), + * or it may be any one or more JavaScript objects. + * @method log + * @for console + * @param {String|Expression|Object} message :Message that you would like to print to the console + * + * @example + *
+ * + * let myNum = 5; + * console.log(myNum); // prints 5 to the console + * console.log(myNum + 12); // prints 17 to the console + * + *
+ */ From ccfd28aa40e862ba6766bbec35ccb62a8e8ac7c9 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Mon, 7 Oct 2019 11:48:15 -0400 Subject: [PATCH 20/27] add while reference and warning about infinite loops --- src/core/reference.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/core/reference.js b/src/core/reference.js index 6e3fa396d6..ac42dd1837 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -236,7 +236,7 @@ */ /** - * for creates a loop that is useful for executing the code multiple times. + * for creates a loop that is useful for executing one section of code multiple times. * * A 'for loop' consists of three different expressions inside of a parenthesis, all of which are optional. * These expressions are used to control the number of times the loop is run. @@ -248,6 +248,12 @@ * The code inside of the loop body (in between the curly braces) is executed between the evaluation of the second * and third expression. * + * As with any loop, it is important to ensure that the loop can 'exit', or that + * the test condition will eventually evaluate to false. The test condition with a for loop + * is the second expression detailed above. Ensuring that this expression can eventually + * become false ensures that your loop doesn't attempt to run an infinite amount of times, + * which can crash your browser. + * * From the MDN entry: * Creates a loop that executes a specified statement until the test condition evaluates to false. * The condition is evaluated after executing the statement, resulting in the specified statement executing at least once. @@ -263,6 +269,40 @@ *
*/ +/** + * while creates a loop that is useful for executing one section of code multiple times. + * + * With a 'while loop', the code inside of the loop body (in between the curly braces) is run repeatedly until the test condition + * (inside of the parenthesis) evaluates to false. Unlike a for loop, the condition is tested before executing the code body with while, + * so if the condition is initially false the loop body, or statement will never execute. + * + * As with any loop, it is important to ensure that the loop can 'exit', or that + * the test condition will eventually evaluate to false. This is to keep your loop from trying to run an infinite amount of times, + * which can crash your browser. + * + * From the MDN entry: + * The while statement creates a loop that executes a specified statement as long as the test condition evaluates to true. + * The condition is evaluated before executing the statement. + * @property while + * + * @example + *
+ * + * // This example logs the lines below to the console + * // 4 + * // 3 + * // 2 + * // 1 + * // 0 + * let num = 5; + * while (num > 0) { + * num = num - 1; + * console.log(num); + * } + * + *
+ */ + /** * @submodule JS Method */ From 3e81ed1b35a80fa1f32a558d2e613101f6fcbb8f Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Mon, 7 Oct 2019 11:52:23 -0400 Subject: [PATCH 21/27] Polygon class to Rectangle class for simplicity --- src/core/reference.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index ac42dd1837..e70a5f8ce5 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -218,14 +218,14 @@ * @example *
* - * class Polygon { + * class Rectangle { * constructor(name, height, width) { * this.name = name; * this.height = height; * this.width = width; * } * } - * let square = new Polygon('square', 1, 1); // creating new instance of Polygon Class. + * let square = new Rectangle('square', 1, 1); // creating new instance of Polygon Class. * console.log(square.width); // prints '1' to the console * *
From 01719e424d20b30ad3f9648dfdfa09c541c7eaf7 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Mon, 7 Oct 2019 11:57:30 -0400 Subject: [PATCH 22/27] Make function example not return value so as to not confuse with return example --- src/core/reference.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index e70a5f8ce5..aa24ccdb17 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -99,10 +99,11 @@ * @example *
* - * function calculateRectArea(width, height) { - * return width * height; + * let myName = 'Hridi'; + * function sayHello(name) { + * console.log('Hello ' + name + '!'); * } - * calculateRectArea(4, 5); // calling the function + * sayHello(myName); // calling the function, prints "Hello Hridi!" to console. * *
*/ From 27204d5ee9ddb52104b0c25e82c4c95a2f2b9d5d Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sat, 12 Oct 2019 15:52:02 -0700 Subject: [PATCH 23/27] Add comparison operator references --- src/core/reference.js | 130 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/core/reference.js b/src/core/reference.js index aa24ccdb17..6d0621136e 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -52,6 +52,136 @@ *
*/ +/** + * @submodule Comparison Operators + */ + +/** + * The equality operator == + * checks to see if two values are equal. + * + * Unlike, the strict equality operator, ===, if + * the values being compared are not already the same type they will be + * converted to the same type before comparison. + * + * A comparison expression always evaluates to a boolean. + * + * From the MDN entry: + * The equality operator converts the operands if they are not of the same type, then applies strict comparison. + * If both operands are objects, then JavaScript compares internal references which are equal when operands refer + * to the same object in memory. + * + * @property == + * + * @example + *
+ * + * console.log(1 == 1) // prints true to the console + * console.log(1 == '1'); // prints true to the console + * + *
+ */ + +/** + * The strict equality operator === + * checks to see if two values are equal and of the same type. + * + * Unlike, the equality operator, ==, + * regardless of whether they are different types + * the values being compared are not converted before comparison. + * + * A comparison expression always evaluates to a boolean. + * + * From the MDN entry: + * The non-identity operator returns true if the operands are not equal and/or not of the same type. + * + * @property === + * + * @example + *
+ * + * console.log(1 == 1) // prints true to the console + * console.log(1 == '1'); // prints false to the console + * + *
+ */ + +/** + * The greater than operator > + * evaluates to true if the left value is greater than + * the right value. + * + * + * There is more info on comparison operators on MDN. + * + * @property > + * + * @example + *
+ * + * console.log(100 > 1) // prints true to the console + * console.log(1 > 100); // prints false to the console + * + *
+ */ + +/** + * The greater than or equal to operator >= + * evaluates to true if the left value is greater than or equal to + * the right value. + * + * + * There is more info on comparison operators on MDN. + * + * @property >= + * + * @example + *
+ * + * console.log(100 >= 100) // prints true to the console + * console.log(101 >= 100); // prints true to the console + * + *
+ */ + +/** + * The less than operator < + * evaluates to true if the left value is less than + * the right value. + * + * + * There is more info on comparison operators on MDN. + * + * @property < + * + * @example + *
+ * + * console.log(1 < 100) // prints true to the console + * console.log(100 < 99); // prints false to the console + * + *
+ */ + +/** + * The less than or equal to operator <= + * evaluates to true if the left value is less than or equal to + * the right value. + * + * + * There is more info on comparison operators on MDN. + * + * @property <= + * + * @example + *
+ * + * console.log(100 <= 100) // prints true to the console + * console.log(99 <= 100); // prints true to the console + * + *
+ */ + /** * @submodule Control Statement */ From e4075793e6600d94e374465bb0b6d7f6ab7d9b54 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sat, 12 Oct 2019 15:53:33 -0700 Subject: [PATCH 24/27] Minor formatting changes --- src/core/reference.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 6d0621136e..40951fd39e 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -76,8 +76,8 @@ * @example *
* - * console.log(1 == 1) // prints true to the console - * console.log(1 == '1'); // prints true to the console + * console.log(1 == 1); // prints true to the console + * console.log('1' == 1); // prints true to the console * *
*/ @@ -100,8 +100,8 @@ * @example *
* - * console.log(1 == 1) // prints true to the console - * console.log(1 == '1'); // prints false to the console + * console.log(1 === 1); // prints true to the console + * console.log(1 === '1'); // prints false to the console * *
*/ @@ -119,7 +119,7 @@ * @example *
* - * console.log(100 > 1) // prints true to the console + * console.log(100 > 1); // prints true to the console * console.log(1 > 100); // prints false to the console * *
@@ -138,7 +138,7 @@ * @example *
* - * console.log(100 >= 100) // prints true to the console + * console.log(100 >= 100); // prints true to the console * console.log(101 >= 100); // prints true to the console * *
@@ -157,7 +157,7 @@ * @example *
* - * console.log(1 < 100) // prints true to the console + * console.log(1 < 100); // prints true to the console * console.log(100 < 99); // prints false to the console * *
@@ -176,7 +176,7 @@ * @example *
* - * console.log(100 <= 100) // prints true to the console + * console.log(100 <= 100); // prints true to the console * console.log(99 <= 100); // prints true to the console * *
From 156087acc51a976c49e3e87f7b825b98c5ba97fd Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 13 Oct 2019 11:07:42 -0700 Subject: [PATCH 25/27] Get rid of == reference, add note in === ref --- src/core/reference.js | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 40951fd39e..ac34059d8d 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -56,45 +56,20 @@ * @submodule Comparison Operators */ -/** - * The equality operator == - * checks to see if two values are equal. - * - * Unlike, the strict equality operator, ===, if - * the values being compared are not already the same type they will be - * converted to the same type before comparison. - * - * A comparison expression always evaluates to a boolean. - * - * From the MDN entry: - * The equality operator converts the operands if they are not of the same type, then applies strict comparison. - * If both operands are objects, then JavaScript compares internal references which are equal when operands refer - * to the same object in memory. - * - * @property == - * - * @example - *
- * - * console.log(1 == 1); // prints true to the console - * console.log('1' == 1); // prints true to the console - * - *
- */ - /** * The strict equality operator === * checks to see if two values are equal and of the same type. * - * Unlike, the equality operator, ==, - * regardless of whether they are different types - * the values being compared are not converted before comparison. - * * A comparison expression always evaluates to a boolean. * * From the MDN entry: * The non-identity operator returns true if the operands are not equal and/or not of the same type. * + * Note: In some examples around the web you may see a double-equals-sign + * ==, + * used for comparison instead. This is the non-strict equality operator in Javascript. + * This will convert the two values being compared to the same type before comparing them. + * * @property === * * @example From aca39e628fc03a9f6002095befd00abef58fd896 Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 13 Oct 2019 13:32:09 -0700 Subject: [PATCH 26/27] Add @static tag to json.stringify and console.log --- src/core/reference.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/reference.js b/src/core/reference.js index ac34059d8d..60eccae23d 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -417,6 +417,7 @@ * From the MDN entry: * The JSON.stringify() method converts a JavaScript object or value to a JSON string. * @method stringify + * @static * @for JSON * @param {Object} object :Javascript object that you would like to convert to JSON * @@ -445,6 +446,7 @@ * The Console method log() outputs a message to the web console. The message may be a single string (with optional substitution values), * or it may be any one or more JavaScript objects. * @method log + * @static * @for console * @param {String|Expression|Object} message :Message that you would like to print to the console * From cf2c4a93ba88313c7851548ad1378cfab829fddb Mon Sep 17 00:00:00 2001 From: Stalgia Grigg Date: Sun, 13 Oct 2019 14:44:03 -0700 Subject: [PATCH 27/27] Minor formatting, cleanup --- src/core/reference.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/reference.js b/src/core/reference.js index 60eccae23d..0279008045 100644 --- a/src/core/reference.js +++ b/src/core/reference.js @@ -6,6 +6,7 @@ /** * Creates and names a new variable. A variable is a container for a value. + * * Variables that are declared with let will have block-scope. * This means that the variable only exists within the * block that it is created within. @@ -31,6 +32,7 @@ * Creates and names a new constant. Like a variable created with let, a constant * that is created with const is a container for a value, * however constants cannot be changed once they are declared. + * * Constants have block-scope. This means that the constant only exists within * the * block that it is created within. A constant cannot be redeclared within a scope in which it @@ -163,8 +165,9 @@ /** * The if-else statement helps control the flow of your code. - * A condition is placed between the parenthesis following 'if'. - * When that condition evalues to truthy, + * + * A condition is placed between the parenthesis following 'if', + * when that condition evalues to truthy, * the code between the following curly braces is run. * Alternatively, when the condition evaluates to falsy, * the code between the curly braces that follow 'else' is run instead. @@ -194,6 +197,7 @@ /** * Creates and names a function. * A function is a set of statements that perform a task. + * * Optionally, functions can have parameters. Parameters * are variables that are scoped to the function, that can be assigned a value when calling the function. * @@ -378,9 +382,9 @@ /** * while creates a loop that is useful for executing one section of code multiple times. * - * With a 'while loop', the code inside of the loop body (in between the curly braces) is run repeatedly until the test condition + * With a 'while loop', the code inside of the loop body (between the curly braces) is run repeatedly until the test condition * (inside of the parenthesis) evaluates to false. Unlike a for loop, the condition is tested before executing the code body with while, - * so if the condition is initially false the loop body, or statement will never execute. + * so if the condition is initially false the loop body, or statement, will never execute. * * As with any loop, it is important to ensure that the loop can 'exit', or that * the test condition will eventually evaluate to false. This is to keep your loop from trying to run an infinite amount of times,