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
+17-17Lines changed: 17 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -209,57 +209,57 @@ alert( date ); // 31 Dec 2015
209
209
210
210
## Date to number, date diff
211
211
212
-
When a `Date`object is converted to number, it becomes the timestamp same as`date.getTime()`:
212
+
Atunci când un obiect `Date`este convertit în număr, acesta devine timestamp-ul la fel ca`date.getTime()`:
213
213
214
214
```js run
215
215
let date =newDate();
216
-
alert(+date); //the number of milliseconds, same as date.getTime()
216
+
alert(+date); //numărul de milisecunde, la fel ca date.getTime()
217
217
```
218
218
219
-
The important side effect: dates can be subtracted, the result is their difference in ms.
219
+
Efect secundar important: datele se pot scădea, rezultatul fiind diferența lor în ms.
220
220
221
-
That can be used for time measurements:
221
+
Acesta poate fi folosit pentru măsurători de timp:
222
222
223
223
```js run
224
-
let start =newDate(); //start measuring time
224
+
let start =newDate(); //începe măsurarea timpului
225
225
226
-
//do the job
226
+
//face treaba
227
227
for (let i =0; i <100000; i++) {
228
228
let doSomething = i * i * i;
229
229
}
230
230
231
-
let end =newDate(); //end measuring time
231
+
let end =newDate(); //încheie măsurarea timpului
232
232
233
-
alert( `The loop took${end - start} ms` );
233
+
alert( `Bucla a durat${end - start} ms` );
234
234
```
235
235
236
236
## Date.now()
237
237
238
-
If we only want to measure time, we don't need the `Date` object.
238
+
Dacă dorim doar să măsurăm timpul, nu avem nevoie de obiectul `Date`.
239
239
240
-
There's a special method`Date.now()`that returns the current timestamp.
240
+
Există o metodă specială`Date.now()`care returnează timestamp-ul curent.
241
241
242
-
It is semantically equivalent to`newDate().getTime()`, but it doesn't create an intermediate `Date`object. So it's faster and doesn't put pressure on garbage collection.
242
+
Aceasta este semantic echivalentă cu`newDate().getTime()`, dar nu creează un obiect `Date`intermediar. Astfel este mai rapidă și nu pune presiune pe garbage collection.
243
243
244
-
It is used mostly for convenience or when performance matters, like in games in JavaScript or other specialized applications.
244
+
Este folosit în mare parte pentru conveniență sau când performanța contează, cum ar fi în jocuri în JavaScript sau alte aplicații specializate.
245
245
246
-
So this is probably better:
246
+
Așa că este probabil mai bine așa:
247
247
248
248
```js run
249
249
*!*
250
-
let start =Date.now(); //milliseconds count from 1 Jan 1970
250
+
let start =Date.now(); //milisecundele se numără de la 1 Ian 1970
0 commit comments