JavaScript Objects: Creation, Manipulation, and Deep Copy Techniques
In JavaScript, objects are collections of key-value pairs used to represent entities with properties and behaviors:
let user = {
name: "Chaoyang",
greet() {
console.log("Hello!");
}
};
Memory Representation
Objects are stored in heap memory. Variables hold references (memory addresses) to these heap-allocated obje ...
Posted on Tue, 11 Aug 2026 16:47:11 +0000 by sofasurfer
Prototype Pattern Implementation in Java
Vector Prototype Implementation
This implementation demonstrates mathematical vector encapsulation in Java with dynamic memory allocation for variable-length vectors. It showcases both shallow and deep cloning techniques for copying vector objects.
Shallow Cloning Approach
In shalow cloning, only the object itself is duplicated, while referance ...
Posted on Tue, 21 Jul 2026 16:21:05 +0000 by yarub
Object Cloning in Java: Shallow, Deep, and Serialization Strategies
Primitive assignments in Java duplicate the actual value:
int count = 10;
int tally = count;
This behavior applies to all eight primitive types. Object variables, however, store memory addresses rather than the objects themselves. Direct assignment therefore creates an alias, not an independent entity:
class Employee {
private int badgeId; ...
Posted on Fri, 05 Jun 2026 18:12:29 +0000 by hand
Understanding Shallow and Deep Copying of Objects in JavaScript
// Assigning a value from a to b
let a = 12;
let b = a;
This method works for primitive types. What happens if a is an object? Let's examine what occurs in memory:
Declaring a = 12 allocates a space in the stack. When a is assigned to b, another space is created in the stack, and b holds the same value as a.
If a is an object, what happens in ...
Posted on Sat, 30 May 2026 21:40:20 +0000 by RootKit
Understanding Object Duplication and Memory Strategies in Objective-C
Object duplication in Objective-C enables developers to generate independent replicas of data structures. This mechanism ensures that alterations made to a derived instance do not mutate the original source. The framework distinguishes between creating immutable and mutable duplicates through two primary instance methods.
Duplication Mechanisms ...
Posted on Sat, 09 May 2026 02:06:47 +0000 by wilzy
Building a Custom String Class in C++
A custom string class typically wraps a dynamically alocated character array along with size and capacity tracking. The following implementation lives inside a dedicated namespace to avoid collisions with the standard library.
namespace custom
{
class string
{
private:
char* _data;
size_t _len;
size_t _cap;
...
Posted on Fri, 08 May 2026 01:30:05 +0000 by BRUUUCE