Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

added 5 characters in body
Source Link
Taki
  • 17.7k
  • 5
  • 29
  • 48

I have an object that I want to use the keys as keys in a new object and the value into a child object. How could I go from A to Z?

'''const a = {key1: 'text', key2: 'text2'}

const z = [{ key1: { similarTo: 'text' } }, {key2: {similarTo: 'test2'}}] '''

const a = {key1: 'text', key2: 'text2'}
const z = [{ key1: { similarTo: 'text' } }, {key2: {similarTo: 'test2'}}] 

I have an object that I want to use the keys as keys in a new object and the value into a child object. How could I go from A to Z?

'''const a = {key1: 'text', key2: 'text2'}

const z = [{ key1: { similarTo: 'text' } }, {key2: {similarTo: 'test2'}}] '''

I have an object that I want to use the keys as keys in a new object and the value into a child object. How could I go from A to Z?

const a = {key1: 'text', key2: 'text2'}
const z = [{ key1: { similarTo: 'text' } }, {key2: {similarTo: 'test2'}}] 
Source Link

Way to iterate through object to create array of objects

I have an object that I want to use the keys as keys in a new object and the value into a child object. How could I go from A to Z?

'''const a = {key1: 'text', key2: 'text2'}

const z = [{ key1: { similarTo: 'text' } }, {key2: {similarTo: 'test2'}}] '''

lang-js

AltStyle によって変換されたページ (->オリジナル) /