Contact: aviboots(AT)netvision.net.il
39,851 questions
51,772 answers
573 users
function f() { const a = 9; const b = 4; const c = 398; return [a, b, c]; } const arr = f(); const x = arr[0]; const y = arr[1]; const z = arr[2]; console.log(x, y, z); /* run: 9 4 398 */
const [x, y, z] = (function(){ return [5, 98, 2]; })(); console.log(x, y, z); /* run: 5 98 2 */
const {x, y, z} = (function(){ return {x: 95, y: 2, z: 8} })(); console.log(x, y, z); /* run: 95 2 8 */
const f = function() { const a = 22; const b = 95; const c = 100; return { vala: a, valb: b, valc: c }; }; const rv = f(); const x = rv.vala; const y = rv.valb; const z = rv.valc; console.log(x, y, z); /* run: 22 95 100 */