Method diffObj documentation
Returns an object describing the differences for transforming the first given object into the second.
Example
```javascript
bbn.fn.diffObj(
{
name: "Thomas",
age: 45
}, {
name: "Eva",
sex: "Female",
retired: false
}
);
// {
// name: {
// type: "updated",
// data: "Thomas",
// newData: "Eva"
// },
// age: {
// type: "deleted",
// data: 45
// },
// sex: {
// type: "created",
// data: "Female"
// },
// retired: {
// type: "created",
// data: false
// }
// }
```
Example
```javascript
bbn.fn.diffObj(
{pupil: "Agnes Varda", grade: {year: "B", month: "A"}},
{pupil: "Luc Besson", grade: {year: "C", month: "D"}}
);
// {
// "pupil": {
// "type": "updated",
// "data": "Agnes Varda",
// "newData": "Luc Besson"
// },
// "grade": {
// "year": {
// "type": "updated",
// "data": "B",
// "newData": "C"
// },
// "month": {
// "type": "updated",
// "data": "A",
// "newData": "D"
// }
// }
// }
```
Returns an object describing the differences for transforming the first given object into the second. - The returned data will use the objects properties as keys. If unchanged is set to true, all the
properties will be returned, otherwise only the different ones. Each of these keys will have the
following properties:
- type: can be _modified_, _created_, _deleted_, and if unchanged is set to true _unchanged_
- data: the first object's property's value, or the second if type is _created_
- newData: the second object's property's value in case of type _updated_
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions