diff --git a/1-js/05-data-types/09-destructuring-assignment/article.md b/1-js/05-data-types/09-destructuring-assignment/article.md index 410e1b40..a87fd5b5 100644 --- a/1-js/05-data-types/09-destructuring-assignment/article.md +++ b/1-js/05-data-types/09-destructuring-assignment/article.md @@ -293,11 +293,11 @@ alert(w); // 100 alert(h); // 200 ``` -### The rest operator +### The rest pattern "..." What if the object has more properties than we have variables? Can we take some and then assign the "rest" somewhere? -Using the rest operator with objects is not supported by some older browsers (use Babel to polyfill it), but works in modern ones. +We can use the rest pattern, just like we did with arrays. It's not supported by some older browsers (IE, use Babel to polyfill it), but works in modern ones. It looks like this: diff --git a/1-js/06-advanced-functions/05-global-object/article.md b/1-js/06-advanced-functions/05-global-object/article.md index 742132aa..96b212bf 100644 --- a/1-js/06-advanced-functions/05-global-object/article.md +++ b/1-js/06-advanced-functions/05-global-object/article.md @@ -47,7 +47,7 @@ window.currentUser = { // somewhere else in code alert(currentUser.name); // John -// or, if we have a local variable with the name "value" +// or, if we have a local variable with the name "currentUser" // get it from window explicitly (safe!) alert(window.currentUser.name); // John ``` @@ -56,7 +56,7 @@ That said, using global variables is generally discouraged. There should be as f ## Using for polyfills -We can test the global object for support of modern language features. +We use the global object to test for support of modern language features. For instance, test if a built-in `Promise` object exists (it doesn't in really old browsers): ```js run @@ -84,4 +84,4 @@ if (!window.Promise) { - We should store values in the global object only if they're truly global for our project. And keep their number at minimum. - In-browser, unless we're using [modules](info:modules), a global variable declared with `var` becomes a property of the global object. - To make the code easier to understand and more future-proof, we should operate directly on the properties of the global object: `window.x = ...` instead of `var x = ...`. + To make the code easier to understand and more future-proof, we should access properties of the global object directly, as `window.x`. diff --git a/3-frames-and-windows/03-cross-window-communication/article.md b/3-frames-and-windows/03-cross-window-communication/article.md index 53cb3cd6..05914a46 100644 --- a/3-frames-and-windows/03-cross-window-communication/article.md +++ b/3-frames-and-windows/03-cross-window-communication/article.md @@ -26,15 +26,17 @@ The "Same Origin" policy states that: - if we have a reference to another window, e.g. a popup created by `window.open` or a window inside ` ``` -Let me know in comments if you know a better solution here. - ## window.frames An alternative way to get a window object for `