Given the below JSBIN why A is undefined?
https://jsbin.com/bisomevivu/edit?html,js,console,output
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input data-custom="CUST" data-standard="STD" id="input">
<button id="button">Test</test>
</body>
</html>
JS:
const [button, input] = ["button", "input"].map(id=> document.getElementById(id));
button.addEventListener("click", ()=>{
const {dataset: {custom}, ...props} = input;
const {value: A} = props;
const {dataset: {standard}, value: B} = input;
console.info(`A: '${A}' - B: '${B}'`);
});
The regular destructuring works, the rest one doesn't
<button>is terminated by</button>, not by</test>. Also remember that you have runnable snippets available: no need for a jsbin lnk, just edit your post and add it as runnable here on SO (without the html/head bits, those are not necessary).valueis not an own property. Hence why...restdoesn't capture it.AandBto be? It looks like perhapsAis supposed to hold the value of theinputelement, and B is supposed to also hold the value of theinput, but just obtained in a slightly less convoluted manner. What are you trying to do?