swc_ecma_compat_es2015

Function instance_of

source
pub fn instance_of() -> impl Pass
Expand description

@babel/plugin-transform-instanceof

§Example

§In

foo instanceof Bar;

§Out

function _instanceof(left, right) {
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
    return !!right[Symbol.hasInstance](left);
  } else {
    return left instanceof right;
  }
}

_instanceof(foo, Bar);