* Skip to main content 
  * Skip to search 
  * Skip to select language 

[ MDN Web Docs  ](/en-US/) Open main menu

  * References  [ References ](/en-US/docs/Web)
    * [ Overview / Web Technology  Web technology reference for developers  ](/en-US/docs/Web)
    * [ HTML  Structure of content on the web  ](/en-US/docs/Web/HTML)
    * [ CSS  Code used to describe document style  ](/en-US/docs/Web/CSS)
    * [ JavaScript  General-purpose scripting language  ](/en-US/docs/Web/JavaScript)
    * [ HTTP  Protocol for transmitting web resources  ](/en-US/docs/Web/HTTP)
    * [ Web APIs  Interfaces for building web applications  ](/en-US/docs/Web/API)
    * [ Web Extensions  Developing extensions for web browsers  ](/en-US/docs/Mozilla/Add-ons/WebExtensions)
    * [ Web Technology  Web technology reference for developers  ](/en-US/docs/Web)
  * Guides  [ Guides ](/en-US/docs/Learn)
    * [ Overview / MDN Learning Area  Learn web development  ](/en-US/docs/Learn)
    * [ MDN Learning Area  Learn web development  ](/en-US/docs/Learn)
    * [ HTML  Learn to structure web content with HTML  ](/en-US/docs/Learn/HTML)
    * [ CSS  Learn to style content using CSS  ](/en-US/docs/Learn/CSS)
    * [ JavaScript  Learn to run scripts in the browser  ](/en-US/docs/Learn/JavaScript)
    * [ Accessibility  Learn to make the web accessible to all  ](/en-US/docs/Web/Accessibility)
  * Plus  [ Plus ](/en-US/plus)
    * [ Overview  A customized MDN experience  ](/en-US/plus)
    * [ AI Help (beta)  Get real-time assistance and support  ](/en-US/plus/ai-help)
    * [ Updates  All browser compatibility updates at a glance  ](/en-US/plus/updates)
    * [ Documentation  Learn how to use MDN Plus  ](/en-US/plus/docs/features/overview)
    * [ FAQ  Frequently asked questions about MDN Plus  ](/en-US/plus/docs/faq)
  * [ Curriculum  New  ](/en-US/curriculum/)
  * [ Blog ](/en-US/blog/)
  * [ Play ](/en-US/play)
  * [ AI Help  Beta  ](/en-US/plus/ai-help)

Search MDN  Clear search input  Search

Theme

  * [ Log in ](/users/fxa/login/authenticate/?next=%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FString%2Fsub)
  * [ Sign up for free  ](/users/fxa/login/authenticate/?next=%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FString%2Fsub)

  1. [ References  ](/en-US/docs/Web)
  2. [ JavaScript  ](/en-US/docs/Web/JavaScript)
  3. [ Reference  ](/en-US/docs/Web/JavaScript/Reference)
  4. [ Standard built-in objects  ](/en-US/docs/Web/JavaScript/Reference/Global_Objects)
  5. [ String  ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
  6. [ String.prototype.sub()  ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub)

Article Actions

  * English (US) 

Filter sidebar  Clear filter input

##  In this article

  * Syntax 
  * Examples 
  * Specifications 
  * Browser compatibility 
  * See also 

  1. [ Standard built-in objects ](/en-US/docs/Web/JavaScript/Reference/Global_Objects)
  2. [ ` String ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
  3. Constructor 
    1. [ ` String() constructor ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/String)
  4. Properties 
    1. [ ` String: length ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
  5. Methods 
    1. [ ` String.prototype[@@iterator]() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/@@iterator)
    2. [ ` String.prototype.anchor() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor) Deprecated 
    3. [ ` String.prototype.at() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at)
    4. [ ` String.prototype.big() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big) Deprecated 
    5. [ ` String.prototype.blink() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink) Deprecated 
    6. [ ` String.prototype.bold() ` ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold) Deprecated 
    7. [ ` String.prototype