JSFiddle - React, Tailwind, and code Playground

by toubia95

JavaScript

var obj = {
  a: 1,
  ab: {
    b: 2,
    c: 3,
    cd: {
      d: new Date(),
      e: 5,
    },
  },
};

var variable = function(a) {
  var ar = a.split(".");
  var al = ar.length;
  var that = obj,
    i = 0;
		/*
  for (i ; i < al; i++) {
    that = that[ar[i]];
  }
	*/
	while (al--) {
    that = that[ar[i]];
		i++;
  }
  if (that instanceof Date && typeof that.getMonth === 'function') {
    alert(a + " = " + that);
  } else {
    alert(a + " ("+that + ") n'est pas une date !");
  }
};

variable("ab.cd.d");
variable("ab.c");

  acte.Jour.prototype.variable = function () {
      function variable(v) {
        const vari = this.variables[v].od;
        return new acte.Jour(vari);
      }

      return variable;
    }();

console.log(new acte.Jour('9/5/1846',false).variable('julien').gregorien());