javascript create object from key value pairs
let items = 'key1:value1;key2:value2;key3:value3';
let items_array = items.split(';');
let final_items = items_array.map(item => item.split(':'));
// [ [ key1, value1 ], [ key2, value2 ], [ key3, value3 ] ]
let final_result = Object.fromEntries(final_items);
// { "key1" : "value1", "key2" : "value2", "key3" : "value3" }
Also in JavaScript:
- remove last comma from string javascript
- loop through object js
- reference error $ is not defined jquery
- query selector click event
- javascript hasownproperty
- react window navigate
- redirect to another domain javascript
- use strict javascript
- function in javascript
- js convert order to char
- 0.1 + 0.2 javascript
- redirect using javascript
- How do you detect whether or not a word is a palindrome in javascript
- compare two dates using moment
- exponent javascript
- form data-request octobercms
- how to lazyload angular
- javascript load image programmatically
- spreadjs autofit column with minimum
- how to get csrf token in javascript
- switch two values each case js
- code to add to cart by javascript
- how to create uuid in javascript
- how to define connection string in appsettings.json