The second example is using the shorthand for ES6's parameter destructuring to extract the item property from the first parameter, assuming it is an object:
function destructure({item}) {
console.log(item);
}
destructure({item: 3}); // logs "3"
The ES5 equivalent would be:
function destructure(arg1) {
var item = arg1.item; // or throw
...
}
This blog post by 2ality has an excellent writeup of destructuring, parameters, and how they play together.
This will throw an error if the first argument to destructure does not have an item property.
You can specify the parameter to destructure or combine this with defaults using:
function ({foo, bar} = param) {
console.log(foo, bar); // the rest of param is not available
}
function ({foo, bar = 11} = param) {
console.log(foo, bar); // bar will be 11 if it was not set in param
}
There are a number of variations on this syntax, but it's the counterpart to the object shorthand syntax:
const item = 3;
destructure({item}); // creates an object like {item: item}