[gjs] Add recommendation for object iteration



commit b28c8b5a97cc3b91645c965d1e7b7ba760c09ad2
Author: Colin Walters <walters verbum org>
Date:   Fri Mar 20 14:42:28 2009 -0400

    Add recommendation for object iteration
    
    This option is shorter to type than the Mozilla-specific "for each"
    syntax, and looks closer to how arrays should be done.
---
 doc/Style_Guide.txt |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/doc/Style_Guide.txt b/doc/Style_Guide.txt
index 2a4a185..2150a92 100644
--- a/doc/Style_Guide.txt
+++ b/doc/Style_Guide.txt
@@ -29,9 +29,14 @@ const GLib = imports.gi.GLib;
 Always use one of "const", "var", or "let" when defining a variable. Always use "let" when block scope is intended; in particular, inside for() and while() loops, let is almost always correct.
 
 <pre>
+// Iterating over an array
 for (let i = 0; i < 10; ++i) {
   let foo = bar(i);
 }
+// Iterating over an object's properties
+for (let prop in someobj) {
+  ...
+}
 </pre>
 
 If you don't use "let" then the variable is added to function scope, not the for loop block scope.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]