object_setDefault

If object does not have key, add it.

As of 2021-06-03. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/427473/937453/object_setDefault.js

// ==UserScript==
// @name         object_setDefault
// @namespace    bo.gd.an[at]rambler.ru
// @version      0.1
// @description  If object does not have key, add it.
// @author       Bogudan
// @license      LGPLv3
// @include      https://localhost/
// ==/UserScript==

object.prototype.setDefault = function (key, value) {
	if (!(key in this))
		this [key] = value;
	};