This question might be ridiculous but I tried searching everywhere but I just can't find a good reference.
Why does some object in javascript has the structure like in the image attached below?
There is t
character. And how do I convert the normal object to that form? For instance:
{
key: "training",
amount: 4500,
currency: "PLN",
label: "Training",
}
CodePudding user response:
The character t
is the class name of the object that is passed as the value of the key value
. As user @Vishnudev mentioned in the comments.
Consider the following code to recreate the JavaScript object and its structure in the image.
Code
class t{
constructor( amount, currency, _sdkType) {
this.amount = amount
this.currency = currency
this._sdkType = _sdkType
}
}
let value = new t(4500, "PLN", "Money")
let object = {
value: value
}
console.log(object)
Output
Result as seen in the browser console.