Practical problems of mixin in js

in "JavaScript you don"t know", there is a paragraph about the inherited mixin implementation. The code is as follows:

function mixin( sourceObj, targetObj ) {//sourceObjtargetObjkey,targetObj
    for (var key in sourceObj) {
// 
        if (!(key in targetObj)) {
            targetObj[key] = sourceObj[key];
        }
    }
    return targetObj;
}
var Vehicle = {
    engines: 1,
    ignition: function() {
        console.log( "Turning on my engine." );
    },
    drive: function() {
        this.ignition();
        console.log( "Steering and moving forward!" );
    }
};
var Car = mixin( Vehicle, {
    wheels: 4,
    drive: function() {
        Vehicle.drive.call( this );
        console.log(
            "Rolling on all " + this.wheels + " wheels!"
        );
    }
} );


Car.drive();

the output is as follows:

Turning on my engine.
Steering and moving forward!
Rolling on all 4 wheels!

just called the drive () method. Why is the content in ignition () printed? Where is it used wrong?

Mar.04,2021

you called ignition


function mixin( sourceObj, targetObj ) {//sourceObjtargetObjkey,targetObj
    for (var key in sourceObj) {
// 
        if (!(key in targetObj)) {
            targetObj[key] = sourceObj[key];
        }
    }
    return targetObj;
}
var Vehicle = {
    engines: 1,
    ignition: function() {
        console.log( "Turning on my engine." );
    },
    drive: function() {
        this.ignition();//CarCarignition
        console.log( "Steering and moving forward!" );
    }
};
var Car = mixin( Vehicle, {//Car
    wheels: 4,
    drive: function() {
        Vehicle.drive.call( this );//Vehicle.drivethis
        console.log(
            "Rolling on all " + this.wheels + " wheels!"
        );
    }
} );


Car.drive();
in drive .
Menu