Object prototype experiment

by Terrance Smith

JavaScript

Object.prototype.isNullOrUndefined = function() {
  //return (this === null || this === undefined || this === '');
  return (this && (this === null || this === undefined));
}

Object.prototype.hasValue = function() {  
  return !(!this);
}

class Person {
  constructor(name) {
    this._name = name;    
  }  

  get name() {
    return this._name;
  }

  set name(val) {
    this._name = val;
  }
}


var a = {};
var b = '';
var c = null;
var d = NaN;
var e;
var bob = new Person('Robert');
var dt = new Date();
var num = 123;


//console.log(a.hasValue());

console.log(c.hasValue());
console.log(d.hasValue());
console.log(e.hasValue());
//console.log(bob.hasValue());
//console.log(dt.hasValue());
//console.log(num.hasValue());