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 5993705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:42:47+00:00 2026-05-22T23:42:47+00:00

I found out earlier today that split() doesn’t work if attached to a single

  • 0

I found out earlier today that split() doesn’t work if attached to a single value.
I would like to write my own split() method so that if I sent it a single value, it creates an array with a single value.

Q: Should I change the split prototype or write a function?

var SPLIT=function(X) {
   return X.toString().split()
}
  • 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-05-22T23:42:47+00:00Added an answer on May 22, 2026 at 11:42 pm

    To clarify, split() does work with a “single value”. The problem in your last question was that the value returned was not a string, and hence the .toString() is necessary.

    In my opinion, there’s no need to write another function for this. Simply remember to convert your values to a string before calling .split() on it.

    If you must have a function that does this, then to answer your question, create a new function and don’t modify the prototype. While it may seem harmless to modify the prototype of Number or Object in this case, it’s generally considered bad practice as other code (e.g. libraries you’re using) may not be expecting it.

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

Sidebar

Related Questions

I would like to upgrade my FluentNHibernate to version 1.1, but I found out
In an earlier question , I've found out that sadly Solution Folders are not
Okay so I was helped earlier with my program question and found out that
I found out that build time of C# solution with many projects gets much
I found out an application I wrote does not work properly under Windows Vista/7
I found out that I can use a different theme in an C# WPF
I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded
I found out that the FormWizard only __init__ 's once, when the url is
I found out recently that JList (finally!) was generified in JDK7. Why JTree and
Just found out that the video output of the iPad is not a system

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.