Message from JavaScript discussions

December 2018

— Dont reinvent the whee!

— 

Hey, I'm trying to decunstructure H = {h: 123, s: 123, v: 123} into h, s, v, but can't get it right.

— const { h, s, v } = H;

— Wait uhhh, let?

— But they are already created above?

— { h, s, v } = H;

— Try that

— Should work

— 

function HSVtoRGB(H, S, V) {
let r;
let g;
let b;
const h = H;
const s = S;
const v = V;
if (arguments.length === 1) {
const { h, s, v } = H;
}

Message permanent page

— Noop, you can't const them if you're gonna modify them later

— 

function convert(h, s, v) {
// conversion logic
}

function HSVtoRGB(H, S, V) {
return arguments.length === 1
? convert(H.h, H.s, H.v)
: convert(H, S, V);
}

Message permanent page

— This is how I would do it