You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/05-data-types/11-date/article.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,13 @@ To create a new `Date` object call `new Date()` with one of the following argume
33
33
34
34
It's a lightweight numeric representation of a date. We can always create a date from a timestamp using `new Date(timestamp)` and convert the existing `Date` object to a timestamp using the `date.getTime()` method (see below).
35
35
36
+
Dates before 01.01.1970 have negative timestamps, e.g.:
37
+
```js run
38
+
// 31 Dec 1969
39
+
let Dec31_1969 = new Date(-24 * 3600 * 1000);
40
+
alert( Dec31_1969 );
41
+
```
42
+
36
43
`new Date(datestring)`
37
44
: If there is a single argument, and it's a string, then it is parsed automatically. The algorithm is the same as `Date.parse` uses, we'll cover it later.
Sometimes people say that `class` is a "syntax sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same without `class` keyword at all:
121
+
Sometimes people say that `class` is a "syntactic sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same without `class` keyword at all:
122
122
123
123
```js run
124
124
// rewriting class User in pure functions
@@ -140,7 +140,7 @@ let user = new User("John");
140
140
user.sayHi();
141
141
```
142
142
143
-
The result of this definition is about the same. So, there are indeed reasons why `class` can be considered a syntax sugar to define a constructor together with its prototype methods.
143
+
The result of this definition is about the same. So, there are indeed reasons why `class` can be considered a syntactic sugar to define a constructor together with its prototype methods.
Here's an example with a computed property in brackets `[...]`:
285
+
Here's an example with a computed property name in brackets `[...]`:
286
286
287
287
```js run
288
288
classUser {
@@ -318,6 +318,9 @@ class User {
318
318
}
319
319
320
320
newUser().sayHi();
321
+
322
+
alert(User.prototype.sayHi); // placed in User.prototype
323
+
alert(User.prototype.name); // undefined, not placed in User.prototype
321
324
```
322
325
323
326
The property `name` is not placed into `User.prototype`. Instead, it is created by `new` before calling the constructor, it's a property of the object itself.
0 commit comments