folks.
I was working on implementations to a (stucked ES5) enterprise compilator and I got some nice implementations like:
Object.prototype.isString = function () { return typeof this[0] === 'string' }
'asd'.isString (); // True
(123).isString (); // False
new Date ().isString (); // False
and
Date.prototype.getArray = function () {
var mm = this.getMonth () + 1;
var dd = this.getDate ();
var arr = new Array ();
arr.push (this.getFullYear ());
arr.push ((mm > 9 ? '' : '0') + mm);
arr.push ((dd > 9 ? '' : '0') + dd);
return arr;
};
var date = new Date ();
date.getArray ()[0]; // 2020 (Year)
date.getArray ()[1]; // 10 (Month)
date.getArray ()[2]; // 21 (Day)
My question is: I'm trying to implement the under snnipet but I'm not getting the equality comparation result. Someone just had made it?
Object.prototype.equals = function (toCompare) { return this === toCompare; }