Function swc_ecma_compat_es2015::instance_of

source ·
pub fn instance_of() -> impl Fold + VisitMut
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);