Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:36:31+00:00 2026-06-04T03:36:31+00:00

A string could be seen as the simplest object that can hold and manipulate

  • 0

A string could be seen as the simplest object that can hold and manipulate text, and as such functions that act on strings should not necessarily be lumped in as methods. On the other hand, javascript is primarily a web programming language, and working with URIs is quite a common use for strings in the language; in this case something like lastName.encodeURIComponent() would actually be quite useful.

Why things like encodeURIComponent and unescape are functions and not methods on the String object? Is there some CS principle at work here, or was it a subjective choice by one of the designers of the language?

Obviously not every function that operates on a string needs to be in the string object, but where and how do people decide where to draw the line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:36:33+00:00Added an answer on June 4, 2026 at 3:36 am

    I don’t think those methods are part of JavaScript but are inherited from window, which is the global object associated with browsers. Thus, while the functions you listed deal with strings, they’re actually closely bound to browser function and thus aren’t attached to the String prototype. Sources like MDN are sort of murky on this but I’m pretty sure that the original JS spec makes no mention of these methods.

    It maybe didn’t make much sense, but nowadays it actually is conceivable that someone might want to use JS as the language of an embedded system or something else that has no Internet association. Here, a syntax that included encodeURIComponent() would be as out of place as document.getElementById().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have strings like this: Car is blue String could also be like this:
I am currently looking into spliting a very long string that could contain HTML
I have a javascript object, that could be something like this { users: [{
I've seen a couple examples out there that could possibly help me, but I
I've got a variable that could either be a string or a tuple (I
For Objective-C in iOS: If I have a string how could I read the
For example, to denote a String I could use: {string,hjggjhhggJ} and a list would
How could a string be formatted depending an am/pm value so it could then
How could i convert this string 03/16/2012 03:22PMusing php to store in datetime format
How could i multiply a string by a number to achieve n amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.