JSFiddle - React, Tailwind, and code Playground
HTML
Object 1 ID: <span id="object-1"></span><br>
Object 2 ID: <span id="object-2"></span>
JavaScript
(function() {
var lastStorageId = 0;
this.Object.hash = function(object) {
var hash = object.__id;
if (!hash)
hash = object.__id = lastStorageId++;
return '#' + hash;
};
}());
var array = [];
var string = 'blub';
var object1 = { bla: string, test: array };
var object2 = { bla: string, test: array };
document.getElementById('object-1').innerHTML = Object.hash(object1);
document.getElementById('object-2').innerHTML = Object.hash(object1);