Implement JS Object into C++

abhay Maurya
1 min readFeb 9, 2021

In JavaScript, almost “everything” is an object, and are mutable hence are addressed by reference, not by value. It is very easy to create an object and access their values. it comprises of key — value pairs. Every key is associated with it’s own value and we can save / access value to corresponding values using keys.

It is very powerfull data structure in terms of coding and competitive problems where we need to store values in key, value pairs.

now question arises how can we do the same thing in C++?

There are lot of data structures available in C++ STL. we can say we have one option map

Creating a JavaScript Object

With JavaScript, you can define and create your own objects. There are different ways to create new objects:

  • Define and create a single object, using an object literal.
let person = { name : “john”, age : 34 }

Define and create a single object, with the keyword new

Creating a JavaScript Object

--

--