In JS, data types are divided into basic data types and reference data types. For basic data types, its value is stored directly in stack memory, while for reference types, it only stores a reference in stack memory, while the real data is stored in heap memory

Undefined, Boolean, number, string, null,

Reference data types Object, Array, Date, RegExp, and Function

Method typeof Instanceof constructor toString

Deep copy method

	let result;
	if(typeof target === 'object') {
		if(Array.isArray(target)) {
			result = [];
			for(let i in target) {
				result.push(deepClone(target[i]));
			}
		} else if(target === null) {
			result = null;
		} else if(target.constructor === RegExp) {
			result = target;
		} else {
			result = {};
			for(let i in target) {
				result[i] = deepClone(target[i]);
			}
		}
	} else {
		result = target;
	}

	return result;
}
Copy the code