JSFiddle - React, Tailwind, and code Playground

NO TITLE (private) Some lib functions: object to string, Vector2D, Obj.

by Laurens Maneschijn

HTML

Some lib functions;
object to string, Vector2D, Obj.
<hr>
<div class="compact">
value_to_string(value)
fix (n,d)
array_unique(arr)
array_diff(arr, arr2)
array_intersect(arr, arr2)
getObjectPropertyNames(object, includeproto)
ObjectToString(object, properties, propsep, keyvalsep)
ObjectToString2(object, options)
Vector2D (x,y) .set() .add() ... etc.
extend(ChildClass, ParentClass)
Obj() .callParentFunction(func, args) .callParentConstructor(args) .getClass() .getParent() etc. 
</div>
<hr>

CSS

textarea {width: 100%; height: 300px;}

.compact {
	line-height:1; font-size: 10px;
}

JavaScript

// https://jsfiddle.net/ElMoonLite/fb6cagL5/
// boilerplate lib stuff:

function value_to_string(value) {
	// with typehints:
	// purpose of output is mostly for debugging:
	// quickly see what type a value is, and easy copy paste of values.
	if (value === null || value === undefined || value === true || value === false || value === Infinity || value === -Infinity ) {
		// NB: These will be returned as same string:
		//     undefined, null, false, true, Infinity, -Infinity
		return '' + value;
	}
	if (typeof value === 'number' && isNaN(value) ) {
		// special case, detecting if value is NaN (and ONLY NaN) is tricky:
		return 'NaN';
	}
	var t = typeof value;
	if (t === 'string') {
//		return 'string:' + value;
		// wrap in quotes
		// pick a quote type that has least occurences in the string (so less escaping needed):
		var cnt_1 = value.split("'").length - 1;
		var cnt_2 = value.split('"').length - 1;
		// note <= : if equal, prefer first (singlequotes).
		if (cnt_1 <= cnt_2) {
			return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'";
		} else {
			return '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
		}
	} else if (t === 'number') {
//		return 'number ' + value;
		return '' + value;
	} else if (Array.isArray(value)) {
		// TODO: recursive for array?
		// TODO: recursion loop protection? maxdepth? break on 2nd visit same value?
		//       e.g. arr = []; arr[0] = arr; value_to_string(a1); Uncaught RangeError: Maximum call stack size exceeded
//		return '[' + value + ']';
//		return 'Array(' + value.length + ') [' + value + '];
		return 'Array(' + value.length + ') [' + value.map(value_to_string).join(', ') + ']';
	} else if (t === 'object') {
		// TODO: recursive for object?
		// TODO: recursion loop protection? maxdepth? break on 2nd visit same value?
		//       e.g. o = {}; o[0] = o; value_to_string(o); Uncaught RangeError: Maximum call stack size exceeded
		var default_tostring = (''+value);
		var is_default_tostring =...