Function polyGetKnownSymbol

  • Returns the polyfill version of a well-known global symbol, this will only return known values.

    Parameters

    • name: string | WellKnownSymbols

      The property name to return (if it exists) for Symbol

    Returns symbol

    The value of the property if present

    // Always returns the polyfill version, even if Symbols are supported in the runtime
    polyGetKnownSymbol("toStringTag") === polyGetKnownSymbol("toStringTag"); // true
    polyGetKnownSymbol(WellKnownSymbols.toStringTag) === polyGetKnownSymbol("toStringTag"); // true
    polyGetKnownSymbol("toStringTag") !== Symbol.toStringTag; // true
    polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== Symbol.toStringTag; // true
    polyGetKnownSymbol("toStringTag") !== polySymbolFor("toStringTag"); // true
    polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== polySymbolFor("toStringTag"); // true
    polyGetKnownSymbol("toStringTag") !== polyNewSymbol("toStringTag"); // true
    polyGetKnownSymbol(WellKnownSymbols.toStringTag) !== polyNewSymbol("toStringTag"); // true