Skip to content

Commit b435be3

Browse files
committed
translated until line 262
1 parent 3cc87cf commit b435be3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

1-js/05-data-types/11-date/article.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -209,57 +209,57 @@ alert( date ); // 31 Dec 2015
209209
210210
## Date to number, date diff
211211
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()`:
213213
214214
```js run
215215
let date = new Date();
216-
alert(+date); // the number of milliseconds, same as date.getTime()
216+
alert(+date); // numărul de milisecunde, la fel ca date.getTime()
217217
```
218218
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.
220220
221-
That can be used for time measurements:
221+
Acesta poate fi folosit pentru măsurători de timp:
222222
223223
```js run
224-
let start = new Date(); // start measuring time
224+
let start = new Date(); // începe măsurarea timpului
225225

226-
// do the job
226+
// face treaba
227227
for (let i = 0; i < 100000; i++) {
228228
let doSomething = i * i * i;
229229
}
230230

231-
let end = new Date(); // end measuring time
231+
let end = new Date(); // încheie măsurarea timpului
232232

233-
alert( `The loop took ${end - start} ms` );
233+
alert( `Bucla a durat ${end - start} ms` );
234234
```
235235
236236
## Date.now()
237237
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`.
239239
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.
241241
242-
It is semantically equivalent to `new Date().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 `new Date().getTime()`, dar nu creează un obiect `Date` intermediar. Astfel este mai rapidă și nu pune presiune pe garbage collection.
243243
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.
245245
246-
So this is probably better:
246+
Așa că este probabil mai bine așa:
247247
248248
```js run
249249
*!*
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
251251
*/!*
252252

253-
// do the job
253+
// face treaba
254254
for (let i = 0; i < 100000; i++) {
255255
let doSomething = i * i * i;
256256
}
257257

258258
*!*
259-
let end = Date.now(); // done
259+
let end = Date.now(); // gata
260260
*/!*
261261

262-
alert( `The loop took ${end - start} ms` ); // subtract numbers, not dates
262+
alert( `Bucla a durat ${end - start} ms` ); // scade numere, nu date
263263
```
264264
265265
## Benchmarking

0 commit comments

Comments
 (0)