diff --git a/1-js/05-data-types/10-date/article.md b/1-js/05-data-types/10-date/article.md index 4a45e500..ace3f932 100644 --- a/1-js/05-data-types/10-date/article.md +++ b/1-js/05-data-types/10-date/article.md @@ -19,7 +19,7 @@ To create a new `Date` object call `new Date()` with one of the following argume ``` `new Date(milliseconds)` -: Create a `Date` obeject with the time equal to number of milliseconds (1/1000 of a second) passed after the Jan 1st of 1970 UTC+0. +: Create a `Date` object with the time equal to number of milliseconds (1/1000 of a second) passed after the Jan 1st of 1970 UTC+0. ```js run // 0 means 01.01.1970 UTC+0 @@ -70,7 +70,7 @@ To create a new `Date` object call `new Date()` with one of the following argume ## Access date components -The are many methods to access the year, month and so on from the `Date` object. But they can be easily remembered when categorized. +There are many methods to access the year, month and so on from the `Date` object. But they can be easily remembered when categorized. `getFullYear()` : Get the year (4 digits) @@ -116,7 +116,7 @@ Besides the given methods, there are two special ones, that do not have a UTC-va : Returns the timestamp for the date -- a number of milliseconds passed from the January 1st of 1970 UTC+0. `getTimezoneOffset()` -: Returns the difference between the local time zene and UTC, in minutes: +: Returns the difference between the local time zone and UTC, in minutes: ```js run // if you are in timezone UTC-1, outputs 60 @@ -227,7 +227,7 @@ alert( `The loop took ${end - start} ms` ); ## Date.now() -If we only want to measure the difference, we don't need `Date` object. +If we only want to measure the difference, we don't need the `Date` object. There's a special method `Date.now()` that returns the current timestamp. @@ -403,10 +403,10 @@ alert(date); ## Summary - Date and time in JavaScript are represented with the [Date](mdn:js/Date) object. We can't create "only date" or "only time": `Date` objects always carry both. -- Months are counted from the zero (yes, January is a zero month). -- Days of week in `getDay()` are also counted from the zero (that's Sunday). +- Months are counted from zero (yes, January is a zero month). +- Days of week in `getDay()` are also counted from zero (that's Sunday). - `Date` auto-corrects itself when out-of-range components are set. Good for adding/substracting days/months/hours. -- Dates can be substructed, giving their difference in milliseconds. That's because a `Date` becomes the timestamp if converted to a number. +- Dates can be substracted, giving their difference in milliseconds. That's because a `Date` becomes the timestamp if converted to a number. - Use `Date.now()` to get the current timestamp fast. Note that unlike many other systems, timestamps in JavaScript are in milliseconds, not in seconds. diff --git a/1-js/05-data-types/11-json/article.md b/1-js/05-data-types/11-json/article.md index ca9b53b0..096570e3 100644 --- a/1-js/05-data-types/11-json/article.md +++ b/1-js/05-data-types/11-json/article.md @@ -21,7 +21,7 @@ let user = { alert(user); // {name: "John", age: 30} ``` -...But in the process of development, new properties are added, old properties are renamed and removed. Updating such `toString` every time can become a pain. We could try to loop over properties in it, but what is the object is complex and has nested objects in properties? We'd need to implement their conversion as well. And, if we're sending the object over a network, then we also need to supply the code to "read" our object on the receiving side. +...But in the process of development, new properties are added, old properties are renamed and removed. Updating such `toString` every time can become a pain. We could try to loop over properties in it, but what if the object is complex and has nested objects in properties? We'd need to implement their conversion as well. And, if we're sending the object over a network, then we also need to supply the code to "read" our object on the receiving side. Luckily, there's no need to write the code to handle all this. The task has been solved already. @@ -68,7 +68,7 @@ alert(json); The method `JSON.stringify(student)` takes the object and converts it into a string. -The resulting `json` string is a called *JSON-encoded* or *serialized* or *stringified* object. We are ready to send it over the wire or put into plain data store. +The resulting `json` string is a called *JSON-encoded* or *serialized* or *stringified* or *marshalled* object. We are ready to send it over the wire or put into plain data store. Please note that JSON-encoded object has several important differences from the object literal: @@ -185,6 +185,7 @@ let json = JSON.stringify(value[, replacer, space]) value : A value to encode. + replacer : Array of properties to encode or a mapping function `function(key, value)`. @@ -478,9 +479,9 @@ alert( meetup.date.getDate() ); // Error! Whoops! An error! -The value of `meetup.date` is a string, not a `Date` object. How `JSON.parse` may know that it should transform that string into a `Date`? +The value of `meetup.date` is a string, not a `Date` object. How could `JSON.parse` know that it should transform that string into a `Date`? -Let's pass to `JSON.parse` the reviving function that returns all values "as is", but `date` wll become a `Date`: +Let's pass to `JSON.parse` the reviving function that returns all values "as is", but `date` will become a `Date`: ```js run let str = '{"title":"Conference","date":"2017-11-30T12:00:00.000Z"}'; diff --git a/1-js/06-advanced-functions/01-recursion/article.md b/1-js/06-advanced-functions/01-recursion/article.md index 8401b5f0..6995cdc4 100644 --- a/1-js/06-advanced-functions/01-recursion/article.md +++ b/1-js/06-advanced-functions/01-recursion/article.md @@ -96,9 +96,9 @@ function pow(x, n) { ``` ```` -The maximal number of nested calls (including the first one) is called *recursion depth*. In our case, it there will be exactly `n`. +The maximal number of nested calls (including the first one) is called *recursion depth*. In our case, it will be exactly `n`. -The maximal recursion depth is limited by JavaScript engine. We can make sure about 10000, some engines allow more, but 100000 is probably out of limit for the majority of them. There are automatic optimizations that help to alleviate this ("tail calls optimizations"), but they are not yet supported everywhere and work only in simple cases. +The maximal recursion depth is limited by JavaScript engine. We can make sure about 10000, some engines allow more, but 100000 is probably out of limit for the majority of them. There are automatic optimizations that help alleviate this ("tail calls optimizations"), but they are not yet supported everywhere and work only in simple cases. That limits the application of recursion, but it still remains very wide. There are many tasks where recursive way of thinking gives simpler code, easier to maintain. @@ -230,7 +230,7 @@ function pow(x, n) { There are no more nested calls, so the function finishes, returning `2`. -As the function finishes, its execution context is not needed any more, so it's removed from the memory. The previous one is restored off-top of the stack: +As the function finishes, its execution context is not needed any more, so it's removed from the memory. The previous one is restored off the top of the stack: