About #2
Wasn't so sure about typescript so I tested it to confirm that it worked.
But in Python3, the default arguments are evaluated at module time loading if I am not mistaken. The following will display roughly the same timestamp
from datetime import datetime
import time
print(datetime.utcnow())
def show_ts(d=datetime.utcnow()):
print(d)
time.sleep(5)
show_ts()
where as in TS, the 2nd one will be roughly 5s older:
const now = Date.now();
console.log(now);
function logTs(d=Date.now()) {
console.log(d);
}
setTimeout(()=> {
logTs();
}, 5000);
Which also means the suggestion to use ?? has a different result then using a default param. ?? will catch both null and undefined, where as a default parameter will only trigger on undefined.
Yes, the logging event is younger, the timestamp displayed is of greater value. Considering the epoch time as the date of birth the displayed timestamp is older.
Probably a translation issue from my native language.