JSFiddle - React, Tailwind, and code Playground
by Hari Menon
JavaScript
'use strict';
var JulianDate = function (year, month, day) {
this.year = year;
this.month = month;
this.day = day;
};
var pad = function (num, size) {
var s = "000000000" + num;
return s.substr(s.length - size);
};
JulianDate.prototype.toString = function () {
return pad(this.year, 4) + " " + pad(this.month, 2) + " " + pad(this.day, 2);
};
function logThemAll(someDate) {
console.log('toString(): ' + someDate.toString());
console.log('typeof: ' + typeof someDate);
console.log('constructor.name: ' + someDate.constructor.name);
console.log('JD.isPrototypeOf: ' + JulianDate.prototype.isPrototypeOf(someDate));
console.log('Date.isPrototypeOf: ' + Date.prototype.isPrototypeOf(someDate));
console.log('Object.getPrototypeOf:' + Object.getPrototypeOf(someDate));
console.log('instanceof JD: ' + someDate instanceof JulianDate);
console.log('instanceof Date: ' + someDate instanceof Date);
}
console.log('Trying to log a \'JulianDate\' object');
var julianDate = new JulianDate(123, 1, 22);
logThemAll(julianDate);
console.log('Now trying to log a \'Date\' object');
var someDate = new Date();
logThemAll(someDate);