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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:07:57+00:00 2026-06-02T14:07:57+00:00

If I have var foo = ‘bar’; , how do I get all the

  • 0

If I have var foo = 'bar';, how do I get all the functions callable on foo, such as toUpperCase? It’s not an object, so Object.getOwnPropertyNames(foo) doesn’t work:

$ node
> var foo = 'bar';
undefined
> console.log(Object.getOwnPropertyNames(foo));
TypeError: Object.getOwnPropertyNames called on non-object
    at Function.getOwnPropertyNames (native)
    at repl:1:20
    at REPLServer.eval (repl.js:80:21)
    at repl.js:190:20
    at REPLServer.eval (repl.js:87:5)
    at Interface.<anonymous> (repl.js:182:12)
    at Interface.emit (events.js:67:17)
    at Interface._onLine (readline.js:162:10)
    at Interface._line (readline.js:426:8)
    at Interface._ttyWrite (readline.js:603:14)

katspaugh’s simple, elegant solution:

> console.log(Object.getOwnPropertyNames(foo.constructor.prototype));
[ 'constructor',
  'length',
  'toLowerCase',
  ... ]
undefined
  • 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-02T14:07:59+00:00Added an answer on June 2, 2026 at 2:07 pm

    The methods you want are on the String.prototype, the prototype of all strings, ruler of Valindor.

    Object.getOwnPropertyNames('baz'.constructor.prototype)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: var foo = '(bar)' foo.replace('(', '').replace(')', '') So, I get bar without
If I have a JS object like: var foo = { 'bar' : 'baz'
I have this object, dive : var dive = new Foo.Bar(); And Foo.Bar looks
I have a object var foo = { jon : {age: 'old', feeling: 'sad'
it appears if you have something like var my_var = {foo : bar}; in
Assign object literal properties var foo = { bar : 'hello'}; Ternary var cats
Let us say I have the following: var foo = (function(){ var bar =
I have the following object: Test.Beta.MyObject = function($) { var foo = {}; foo.blah
I have an object, defined thus: var obj = { 'title': 'foo', 'id': '123',
Basically: I have this HTML: <div id=foo><img src=/foo/bar/{var}/foo alt={var}></div> When calling (using jQuery in

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.