javascript destructuring parameters

Mar 28, 09:33 AM

2022-04-01:

function tryMe({one, two, three}) { console.log(one, two,three) ; }

const tmp = { one: 1, two: 2, three: 3 } ;

tryMe(tmp) ;

=========================================

https://www.sitepoint.com/community/t/promises-feedback/384246/3

consider passing an JSON object for parms in the future:

function tester({param}) { console.log(JSON.stringify(param));
}
tester({param: { ‘parmOne’: 123, ‘paramTwo’: “two”}}) ;

===========

REPLACE:

function desiredCar(eachCar) { const make = eachCar.make; const model = eachCar.model; const hp = eachCar.hp; // then do stuff with make, model, and hp
}

WITH:

function desiredCar({make, model, hp}) {

}

=======

Mark Edwards

,

---

Commenting is closed for this article.

---