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

  • Home
  • SEARCH
  • 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 841133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:44:35+00:00 2026-05-15T05:44:35+00:00

In javascript you can call a function as a function or as a constructor.

  • 0

In javascript you can call a function as a function or as a constructor. For example you can do :

myObject = new Number(13);
myPrimitiveValue = Number(13);

or simply

myPrimitiveValue = 13;

I understand the difference between the results. Can you explain me under which reasonable circumstances creating a number, a boolean or a string as an object is desirable? For example, ability to set new properties (this is something you can do on objects but can’t really do on primitive values) is almost always a bad idea for objects containing number/boolean/string. Why would I want a numeric/boolean/string object?

  • 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-15T05:44:36+00:00Added an answer on May 15, 2026 at 5:44 am

    You rarely have to create objects for the basic data types.

    From the Microsoft documentation of the Number object:

    “The Number object is a wrapper for
    numeric data. The primary purposes for
    the Number object are to collect its
    properties into one object and to
    allow numbers to be converted into
    strings via the toString method. The
    Number object is similar to the
    Number data type. However, they have
    different properties and methods.

    You rarely need to construct a Number
    object explicitly. The Number data
    type should be used in most
    circumstances. Since the Number object
    interoperates with the Number data
    type, all Number object methods and
    properties are available to a variable
    of type Number.”

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

Sidebar

Related Questions

Is there any way that I can call a JavaScript function via css? For
Can you call a Javascript function that expects let's say five arguments, and supply
Is there any way I can make Firefox call a JavaScript function in my
A nasty gotcha in javascript is forgetting to call new on a function meant
In iOS, how can I call an Objective-C method from Javascript in a UIWebView
Given an instantiated JavaScript object/class can I make an Ajax call from that class
I'd like an example of how to access and call Javascript object properties and
When I want to call a function in javascript with arguments supplied from elsewhere
There is a way to call javascript function from webview and then let it
The question In Javascript, how can an event handler function refer to members 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.