Merge pull request #1837 from corbanmailloux/patch-2

[javascript/en] Spacing and capitalization of comments
This commit is contained in:
Adam Brenecki 2015-10-28 13:18:37 +10:30
commit 9d2efe69d0

View File

@ -136,7 +136,7 @@ undefined; // used to indicate a value is not currently present (although
// character.
var someVar = 5;
// if you leave the var keyword off, you won't get an error...
// If you leave the var keyword off, you won't get an error...
someOtherVar = 10;
// ...but your variable will be created in the global scope, not in the scope
@ -145,7 +145,7 @@ someOtherVar = 10;
// Variables declared without being assigned to are set to undefined.
var someThirdVar; // = undefined
// if you want to declare a couple of variables, then you could use a comma
// If you want to declare a couple of variables, then you could use a comma
// separator
var someFourthVar = 2, someFifthVar = 4;
@ -223,15 +223,15 @@ for (var i = 0; i < 5; i++){
// will run 5 times
}
//The For/In statement loops iterates over every property across the entire prototype chain
// The for/in statement iterates over every property across the entire prototype chain.
var description = "";
var person = {fname:"Paul", lname:"Ken", age:18};
for (var x in person){
description += person[x] + " ";
}
//If only want to consider properties attached to the object itself,
//and not its prototypes use hasOwnProperty() check
// To only consider properties attached to the object itself
// and not its prototypes, use the `hasOwnProperty()` check.
var description = "";
var person = {fname:"Paul", lname:"Ken", age:18};
for (var x in person){
@ -240,8 +240,9 @@ for (var x in person){
}
}
//for/in should not be used to iterate over an Array where the index order is important.
//There is no guarantee that for/in will return the indexes in any particular order
// For/in should not be used to iterate over an Array where the index order
// is important, as there is no guarantee that for/in will return the indexes
// in any particular order.
// && is logical and, || is logical or
if (house.size == "big" && house.colour == "blue"){
@ -256,7 +257,7 @@ var name = otherName || "default";
// The `switch` statement checks for equality with `===`.
// use 'break' after each case
// Use 'break' after each case
// or the cases after the correct one will be executed too.
grade = 'B';
switch (grade) {