Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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" }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript how to convert string to number 
Javascript :: Define Number Prop Vue 
Javascript :: prompt in javascript 
Javascript :: Kendo Grid export to Excel not working with large data 
Javascript :: node express 
Javascript :: regex for fullstop 
Javascript :: phantomjs in angular 
Javascript :: jquery public function 
Javascript :: create slug using middleware 
Javascript :: Using Props In React: Assigning CSS 
Javascript :: creating room in ws nodejs 
Javascript :: dayofmonth mongodb 
Javascript :: javascript string to boolean 
Javascript :: json server start code 
Javascript :: moyenne javascript 
Javascript :: async arrow function javascript 
Javascript :: Error: [Home] is not a <Route component. All component children of <Routes must be a <Route or <React.Fragment 
Javascript :: javascript check if url ends with slash 
Javascript :: buscar una frase e un string js 
Javascript :: javascript compare timestamp 
Javascript :: jquery append method 
Javascript :: ternary operator js 
Javascript :: regex contains special characters javascript 
Javascript :: extends in js 
Javascript :: js queryselectorall 
Javascript :: window.print() specific div 
Javascript :: call by value and call by reference in javascript 
Javascript :: comments in js 
Javascript :: javascript url 
Javascript :: regex javascript online 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =