Answers for "mixins javascript"

1

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!"
Posted by: Guest on February-24-2021
0

What is a Mixin?

/*
	Mixins are Sass functions that group CSS declarations together.
	We can reuse them later like variables.

	We can create a mixin with @mixin ex: @mixin variable-name {}
	
	we can create a mixin as a function show below and add parameters as well

	After creating the mixin, we can use it in any class with @include command.
	
	This approach simplifies the code.
*/

/****example-1****/
@mixin my-flex {
  display:flex;
  align-items:center;
  justify-content:center;
}

/****example-2****/
$font-color: red;
@mixin my-font($font-color) {...}

/****HOW TO USE****/
div { 
  @include my-flex; 
}
Posted by: Guest on October-27-2020
-2

mixin in js

shantay
Posted by: Guest on June-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language