can we use object in a function javascript code example
Example 1: object object javascript
person = {
'name':'john smith'
'age':41
};
console.log(person);
//this will return [object Object]
//use
console.log(JSON.stringify(person));
//instead
Example 2: Object as a Function
const profileUpdate = ({ name, age, nationality, location }) => {
/* do something with these fields */
}
Example:
const stats = {
max: 56.78,
standard_deviation: 4.34,
median: 34.54,
mode: 23.87,
min: -0.75,
average: 35.85
};
const half = ({ max, min }) => (max + min) / 2.0;
console.log(half(stats)); //28.015