From 93eddd8f8a6845e69466bc64b0c2fec15e422ffa Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:25:53 +0100 Subject: [PATCH 1/8] Minor typos --- docs/classes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/classes.md b/docs/classes.md index 314295742..aa650291f 100644 --- a/docs/classes.md +++ b/docs/classes.md @@ -234,7 +234,7 @@ console.log(Foo.prototype); // {} i.e. it exists and is not undefined console.log(Foo.prototype.constructor === Foo); // Has a member called `constructor` pointing back to the function ``` -Now lets look at *effect of `new` on `this` inside the called function*. Basically `this` inside the called function is going to point to the newly created object that will be returned from the function. Its simple to see if you mutate a property on `this` inside the function: +Now lets look at *effect of `new` on `this` inside the called function*. Basically `this` inside the called function is going to point to the newly created object that will be returned from the function. It's simple to see if you mutate a property on `this` inside the function: ```ts function Foo() { @@ -270,7 +270,7 @@ But wait we wanted `d.prototype.__proto__` i.e. just the proto changed and maint #### `d.prototype.__proto__ = b.prototype` significance -The significance is that it allows you to add members functions to a child class and inherit other from the base class. This is demonstrated by the following simple example: +The significance is that it allows you to add member functions to a child class and inherit others from the base class. This is demonstrated by the following simple example: ```ts function Animal() { } From 2efe1f2dfa872abf0bcc3f7bdd8b7445591007bf Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:30:22 +0100 Subject: [PATCH 2/8] Minor typo --- docs/arrow-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/arrow-functions.md b/docs/arrow-functions.md index 220a3f3c2..4192caf6d 100644 --- a/docs/arrow-functions.md +++ b/docs/arrow-functions.md @@ -2,7 +2,7 @@ Lovingly called the *fat arrow* (becuase `->` is a thin arrow and `=>` is a fat arrow) and also called a *lambda function* (because of other languages). Another commonly used feature is the fat arrow function `()=>something`. The motivation for a *fat arrow* is: 1. You don't need to keep typing `function` -1. I lexically captures the meaning of `this` +1. It lexically captures the meaning of `this` For a language that claims to be functional, in JavaScript you tend to be typing `function` quite a lot. The fat arrow makes it simple for you to create a function ```ts @@ -76,4 +76,4 @@ person.growOld(); ``` then `this` is going to be the correct calling context (in this example `person`). -{% include "footer.md" %} \ No newline at end of file +{% include "footer.md" %} From 24ab78bcbd4766ee5bb9f8fd3f4f5bfb975439fe Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:31:04 +0100 Subject: [PATCH 3/8] Minor typo. --- docs/arrow-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/arrow-functions.md b/docs/arrow-functions.md index 4192caf6d..f148a06b0 100644 --- a/docs/arrow-functions.md +++ b/docs/arrow-functions.md @@ -2,7 +2,7 @@ Lovingly called the *fat arrow* (becuase `->` is a thin arrow and `=>` is a fat arrow) and also called a *lambda function* (because of other languages). Another commonly used feature is the fat arrow function `()=>something`. The motivation for a *fat arrow* is: 1. You don't need to keep typing `function` -1. It lexically captures the meaning of `this` +2. It lexically captures the meaning of `this` For a language that claims to be functional, in JavaScript you tend to be typing `function` quite a lot. The fat arrow makes it simple for you to create a function ```ts From d77f7d64984d0c9dbc3d3822802f5058e90e2d14 Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:40:05 +0100 Subject: [PATCH 4/8] Minor typos. --- docs/let.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/let.md b/docs/let.md index a13939947..b51718615 100644 --- a/docs/let.md +++ b/docs/let.md @@ -108,7 +108,7 @@ for (var j = 0; j < 3; j++) { funcs[j](); } ``` -Here the functions close over (hence called a `closure`) the *local* variable (conviniently named `local`) and use that instead of the loop variable `i`. Note that closures come with a performance impact (they need to store the surrounding state) and therefore even though the ES6 `let` keyword in a loop would have the same behavior as the previous example, the following is an error in TypeScript if you target something less that ES6: +Here the functions close over (hence called a `closure`) the *local* variable (conveniently named `local`) and use that instead of the loop variable `i`. Note that closures come with a performance impact (they need to store the surrounding state) and therefore even though the ES6 `let` keyword in a loop would have the same behavior as the previous example, the following is an error in TypeScript if you target something less than ES6: ```ts var funcs = []; @@ -133,4 +133,4 @@ Despite a few limitations, we find `let` to be extremely useful to have for the {% include "footer.md" %} -[](https://github.com/olov/defs/blob/master/loop-closures.md) \ No newline at end of file +[](https://github.com/olov/defs/blob/master/loop-closures.md) From d4d0291ac8698bcd77ea1e9ad510959d13993c12 Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:42:53 +0100 Subject: [PATCH 5/8] Minor typos. --- docs/destructuring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/destructuring.md b/docs/destructuring.md index e57cde938..b11de0a81 100644 --- a/docs/destructuring.md +++ b/docs/destructuring.md @@ -15,7 +15,7 @@ var rect = { x: 0, y: 10, width: 15, height: 20 }; var {x, y, width, height} = rect; console.log(x, y, width, height); // 0,10,15,20 ``` -Here in the absence of destructing you would have to pick off `x,y,width,height` one by one from `rect`. +Here in the absence of destructuring you would have to pick off `x,y,width,height` one by one from `rect`. #### Array Destructuring A common programming question : Swap two variables without using a third one. The TypeScript solution: @@ -59,7 +59,7 @@ var _a; ``` #### Summary -Destructuring can make your code more readable and maintainable by reducing the line count and making the intent clear. Array destructuring can allow to use arrays as though they were tuples. +Destructuring can make your code more readable and maintainable by reducing the line count and making the intent clear. Array destructuring can allow you to use arrays as though they were tuples. {% include "footer.md" %} From 44de15f957d4eb276f4a7e7320ef15f40824d2fa Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:46:05 +0100 Subject: [PATCH 6/8] Minor typo. --- docs/for...of.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/for...of.md b/docs/for...of.md index 972c92900..31bb110d5 100644 --- a/docs/for...of.md +++ b/docs/for...of.md @@ -58,6 +58,6 @@ for (let paragraph of articleParagraphs) { Use `for...of` only for stuff that *you know* to be an array or a string. Note that this limitation might be removed in a future version of TypeScript. #### Summary -You would be surprised at how many times you will be iterating over the elements of an array. The next time you find yourself doing that, give `for...of` a go. You might just make the next person who reviews you code happy. +You would be surprised at how many times you will be iterating over the elements of an array. The next time you find yourself doing that, give `for...of` a go. You might just make the next person who reviews your code happy. {% include "footer.md" %} From 97ab8e770e53bef9a87700a4fe06bbc9244ba739 Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:52:45 +0100 Subject: [PATCH 7/8] Minor typos. --- docs/template-strings.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/template-strings.md b/docs/template-strings.md index 81311a514..5af128490 100644 --- a/docs/template-strings.md +++ b/docs/template-strings.md @@ -21,7 +21,7 @@ Never gonna let you down`; ``` #### String Interpolation -Another common use case is when you want to generate some string out of some static strings + some variables. For this you would need some *templating logic* and this is where *template strings* get there name from. Here's how you would potentially generate an html string previously: +Another common use case is when you want to generate some string out of some static strings + some variables. For this you would need some *templating logic* and this is where *template strings* get their name from. Here's how you would potentially generate an html string previously: ```ts var lyrics = 'Never gonna give you up'; @@ -77,6 +77,6 @@ function htmlEscape(literals, ...placeholders) { For pre ES6 compile targets the code is fairly simple. Multiline strings become escaped strings. String interpolation becomes *string concatenation*. Tagged Templates become function calls. #### Summary -Multiline strings and string interpolation are just great things to have in any language. Its great that you can now use them in your JavaScript (thanks TypeScript!). Tagged templates allow you to create powerful string utilities. +Multiline strings and string interpolation are just great things to have in any language. It's great that you can now use them in your JavaScript (thanks TypeScript!). Tagged templates allow you to create powerful string utilities. -{% include "footer.md" %} \ No newline at end of file +{% include "footer.md" %} From 39b64e3a79c786c408d5023cd22634ac901f883e Mon Sep 17 00:00:00 2001 From: Dave Willmer Date: Sun, 24 May 2015 13:56:42 +0100 Subject: [PATCH 8/8] Minor typos. --- docs/spread-operator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/spread-operator.md b/docs/spread-operator.md index a945aa090..59d639c04 100644 --- a/docs/spread-operator.md +++ b/docs/spread-operator.md @@ -3,7 +3,7 @@ The main objective of the spread operator is to *spread* the objects of an array. This is best explained with examples. #### Apply -A common use case it to spread an array into the function arguments. Previously you would need to use `Function.prototype.apply`: +A common use case is to spread an array into the function arguments. Previously you would need to use `Function.prototype.apply`: ```ts function foo(x, y, z) { } @@ -40,6 +40,6 @@ console.log(list); // [1,2,3,4] ``` #### Summary -`apply` is something that you would inevitably do in JavaScript, so its good to have a better syntax where you don't have that ugly `null` for the `this` argument. Also having a dedicated syntax for moving arrays out of (destructuring) or into (assignment) other arrays provides neat syntax for when you are doing array processing on partial arrays. +`apply` is something that you would inevitably do in JavaScript, so it's good to have a better syntax where you don't have that ugly `null` for the `this` argument. Also having a dedicated syntax for moving arrays out of (destructuring) or into (assignment) other arrays provides neat syntax for when you are doing array processing on partial arrays. {% include "footer.md" %}