what is mixins in javascript code example
Example 1: What is a Mixin?
@mixin my-flex {
display:flex;
align-items:center;
justify-content:center;
}
$font-color: red;
@mixin my-font($font-color) {...}
div {
@include my-flex;
}
Example 2: mixins javascript
let bird = {
name: "Donald",
numLegs: 2
};
let plane = {
model: "777",
numPassengers: 524
};
let flyMixin = function(obj) {
obj.fly = function() {
console.log("Flying, wooosh!");
}
};
flyMixin(bird);
flyMixin(plane);
bird.fly(); // "Flying, wooosh!"
plane.fly(); // "Flying, wooosh!"