Contact: aviboots(AT)netvision.net.il
40,761 questions
53,136 answers
573 users
function f() { const a = 9; const b = 4; const c = 298; 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, 298 */
const [x, y, z] = (function(){ return [5, 8, 2]; })(); console.log(x, y, z); /* run: 5, 8, 2 */
const {x, y, z} = (function(){ return {x: 5, y: 2, z: 9} })(); console.log(x, y, z); /* run: 5, 2, 9 */
const f = function() { const a = 22; const b = 65; const c = 89; 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, 65, 89 */