From e2d5e58e198002d5effeba404b848464bf169e9b Mon Sep 17 00:00:00 2001 From: Deepak Dhayatker Date: Sun, 3 Mar 2019 14:57:53 +0000 Subject: [PATCH 1/4] Update ch1.md I think a Russian doll is better analogy of scope lookup than a building --- scope & closures/ch1.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scope & closures/ch1.md b/scope & closures/ch1.md index af5049413..02db2ef4c 100644 --- a/scope & closures/ch1.md +++ b/scope & closures/ch1.md @@ -236,10 +236,12 @@ To visualize the process of nested *Scope* resolution, I want you to think of th -The building represents our program's nested *Scope* rule set. The first floor of the building represents your currently executing *Scope*, wherever you are. The top level of the building is the global *Scope*. +The building represents our program's nested *Scope* rule set. The first floor of the building represents your currently executing *Scope*, wherever you are. The top level of the building is the global *Scope*. -You resolve LHS and RHS references by looking on your current floor, and if you don't find it, taking the elevator to the next floor, looking there, then the next, and so on. Once you get to the top floor (the global *Scope*), you either find what you're looking for, or you don't. But you have to stop regardless. +You resolve LHS and RHS references by looking on your current floor, and if you don't find it, taking the elevator to the next floor, looking there, then the next, and so on. Note that LHS And RHS references and not checked in the other flats on teh samce level, just upwards. Once you get to the top floor (the global *Scope*), you either find what you're looking for, or you don't. But you have to stop regardless. + A better analogy is that of a Russian doll. Where several dolls are nested within each other. And you look for the reference in the current doll. If you dont find it you ask the outer doll and keeping asking each outer doll. If the biggest doll (the outer most doll is the global scope) does not have the refernce you are looking for then you stop. + ## Errors Why does it matter whether we call it LHS or RHS? From e09d1f7218060e57b8cc3574a96a656f4f128e48 Mon Sep 17 00:00:00 2001 From: Deepak Dhayatker Date: Sun, 3 Mar 2019 15:02:05 +0000 Subject: [PATCH 2/4] Update ch1.md I think a Russian doll is better analogy of scope lookup than a building --- scope & closures/ch1.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scope & closures/ch1.md b/scope & closures/ch1.md index 02db2ef4c..017a4d6fa 100644 --- a/scope & closures/ch1.md +++ b/scope & closures/ch1.md @@ -238,9 +238,9 @@ To visualize the process of nested *Scope* resolution, I want you to think of th The building represents our program's nested *Scope* rule set. The first floor of the building represents your currently executing *Scope*, wherever you are. The top level of the building is the global *Scope*. -You resolve LHS and RHS references by looking on your current floor, and if you don't find it, taking the elevator to the next floor, looking there, then the next, and so on. Note that LHS And RHS references and not checked in the other flats on teh samce level, just upwards. Once you get to the top floor (the global *Scope*), you either find what you're looking for, or you don't. But you have to stop regardless. +You resolve LHS and RHS references by looking on your current floor, and if you don't find it, taking the elevator to the next floor, looking there, then the next, and so on. Note that LHS And RHS references and not checked in the other flats on the same level, just upwards. Once you get to the top floor (the global *Scope*), you either find what you're looking for, or you don't. But you have to stop regardless. - A better analogy is that of a Russian doll. Where several dolls are nested within each other. And you look for the reference in the current doll. If you dont find it you ask the outer doll and keeping asking each outer doll. If the biggest doll (the outer most doll is the global scope) does not have the refernce you are looking for then you stop. + A better analogy is that of a Russian doll. Where several dolls are nested within each other. And you look for the reference in the current executing doll. If you dont find it you ask the outer doll and keeping asking each outer doll. You dont ask for the reference to its inner doll. If the biggest doll (the outer most doll is the global scope) does not have the refernce you are looking for then you stop. ## Errors From dd25e459940d9435cc1d8e88a7cec315fedad685 Mon Sep 17 00:00:00 2001 From: Deepak Dhayatker Date: Sun, 24 Mar 2019 10:31:56 +0000 Subject: [PATCH 3/4] Update ch4.md The stringfy method does not limit the indentation to 10 chars. it was upto 10 characters only in given example. I tried this and mor than 10 characters were used to indent. Code function startJS() { var testa = { b:42, c: "42", d: [1,2,3] } var result = JSON.stringify(testa, function(k,v){ return v; },"-----------") console.log("total result = " + result); } output total result = { ----------"b": 42, ----------"c": "42", ----------"d": [ --------------------1, --------------------2, --------------------3 ----------] } --- types & grammar/ch4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types & grammar/ch4.md b/types & grammar/ch4.md index 951bd43c7..afbe132bf 100644 --- a/types & grammar/ch4.md +++ b/types & grammar/ch4.md @@ -203,7 +203,7 @@ JSON.stringify( a, function(k,v){ **Note:** In the `function` *replacer* case, the key argument `k` is `undefined` for the first call (where the `a` object itself is being passed in). The `if` statement **filters out** the property named `"c"`. Stringification is recursive, so the `[1,2,3]` array has each of its values (`1`, `2`, and `3`) passed as `v` to *replacer*, with indexes (`0`, `1`, and `2`) as `k`. -A third optional argument can also be passed to `JSON.stringify(..)`, called *space*, which is used as indentation for prettier human-friendly output. *space* can be a positive integer to indicate how many space characters should be used at each indentation level. Or, *space* can be a `string`, in which case up to the first ten characters of its value will be used for each indentation level. +A third optional argument can also be passed to `JSON.stringify(..)`, called *space*, which is used as indentation for prettier human-friendly output. *space* can be a positive integer to indicate how many space characters should be used at each indentation level. Or, *space* can be a `string`, in which the given string will be used to indent each level. ```js var a = { From cd6fadd9fbca7c4b27fa28f2c58c2259c1151bbf Mon Sep 17 00:00:00 2001 From: Deepak Dhayatker Date: Sun, 24 Mar 2019 10:33:35 +0000 Subject: [PATCH 4/4] Update ch4.md Its better to have the same output /test to see the example work --- types & grammar/ch4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types & grammar/ch4.md b/types & grammar/ch4.md index afbe132bf..d7207b7e1 100644 --- a/types & grammar/ch4.md +++ b/types & grammar/ch4.md @@ -193,7 +193,7 @@ var a = { d: [1,2,3] }; -JSON.stringify( a, ["b","c"] ); // "{"b":42,"c":"42"}" +JSON.stringify( a, ["b","d"] ); // "{"b":42,"d":[1,2,3]}" JSON.stringify( a, function(k,v){ if (k !== "c") return v;