fabric.util.object.extend is the same as Object.assign, which kind of makes the code cognitively simpler to understand.
Aside from that, it looks like it masks to old obj.toObject function, which is assumed to exist and return an object prior to calling extend(obj, someId), with another function called toObject, which calls to old toObject, which returns some object, that assigned the properties found in the second parameter object, which is just id, with the value id that was passed to extend.
When you call extend with some object that doesn't contain a toObject function, it throws a TypeError: Cannot read property 'call' of undefined at Object.obj.toObject.toObject