3 ms·
Yes, it creates an object with key as the value of path and value the value of payload. If path=1, payload=2, this call would make the object {‘1’: 2 }
by wrkronmiller 7y ago
Yes, it creates an object with key as the value of path and value the value of payload. If path=1, payload=2, this call would make the object {‘1’: 2 }
- jcampbell1 7y agoThat is what I thought, and if path = ['foo','bar'] and payload = 2, it makes {'foo,bar',2}. It is for sure making max use of dynamic programming. Typescript accepts it as {[path as any]: payload} which is pulling ejection lever on typescript. Glad I learned something new from this.
- PudgePacket 7y agoIt's just a nice quality of life improvement compared to const obj = {}; obj[foo] = 10;