It's about, why I prefer this function over using 'new Map()' *.set()?
First the code:
export async function createObjects(...args){
const [map_object = null, map_entries = null] = args;
if(map_object !== null && map_entries !== null){
const map = new Map([[map_object,map_entries]]);
return map.get(map_object);
}
return null;
};
The advances of this function over using
*.set('key1', 'value1');
*.set('key2', 'value2');
It can be used in the same way as using an ordinary object structure, doing the same thing as 'set' and is much shorter;
const foo = {key1: val1,key2: val2,};
const bar = await FT.createObjects('bar_obj',{key1: val1,key2: val2,});
or
const foo = {};
foo.key1 = val1;
foo.key2 = val2;
// 'FT' is a namespace and is from 'import * as FT from "...js"'!
const bar = await FT.createObjects('bar_obj',{});
bar.key1 = val1;
bar.key2 = val2;
bar['key1'] = val1;
bar['key2'] = val2;
Note:
It's used in:
My recently created '*ModuleEditer' and wherover more at a later stage.
- (*)Is part of my present GH page aadswebdesign
My present rebuild of my github page and wherover more at a later stage too.
- Also, I do this rebuild on my localhost and I will replace my present GH page, when the time is right for it.
That's it!
Top comments (0)