Prototype-based Inheritance in JavaScript with Constructors using Object.create()

// Create an empty object const object1 = {}; // Create a unique symbol 'a' a = Symbol('a'); // Retrieve or create a symbol with key 'b' b = Symbol.for('b'); // Assign 'Carry' to the property keyed by symbol 'a' object1[a] = 'Carry'; // Assign 'Marry' to the property keyed by symbol 'b' object1[b] = 'Marry'; // Get an array of symbols belonging to object1 const objectSymbols = Object.getOwnPropertySymbols(object1); // Output the length of the array containing symbols console.log(objectSymbols.length);

Output: