• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. WorkerLocation
  4. WorkerLocation.port

Table of contents

  • Syntax
  • Examples
  • Specifications
  • Browser compatibility
  • See also

WorkerLocation.port

The port property of a WorkerLocation object returns the port part of the worker's location.

Syntax

string = location.port;

Examples

// In a Web worker, on the page http://localhost:8080/
var result = location.port; // Returns '8080'

Specifications

Specification
HTML Standard
# dom-workerlocation-port

Browser compatibility

BCD tables only load in the browser

See also

  • The WorkerLocation interface it belongs to.

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Feb 18, 2022, by MDN contributors

Related Topics

  1. WorkerLocation
  2. Properties
    1. hash
    2. host
    3. hostname
    4. href
    5. origin
    6. pathname
    7. port
    8. protocol
    9. search
  3. Methods
    1. toString()
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies