'constructing object with key value and value accepting space in js

I might be wrong , but curious to know whether can i construct an object with key value pair, with value accepting space only

Somehow after parsing i need to get as

properties:
    name:
    value:       //accepting space



let property = { name: {'value':} }; //currently its giving me error like expression expected

I need to give something like this , is it possible in js or in react Any help will be highly appreciated



Solution 1:[1]

You can create objects with undefined or null values, like this:

let property = {
  name: undefined,
  value: undefined
}

let null_property = {
  name: null,
  value: null
}

which is the closest you can get to 'empty space' in Javascript, if you mean what I think you mean.

You can't, however, not assign anything at all in your syntax because Javascript requires that something be assigned to every single variable. You can test this by noting that:

let thing;

and

let thing = undefined;

are the EXACT same line of code from your computer's perspective. The first is simply a convenient shorthand way to write the second.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mitchazj