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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:05:06+00:00 2026-06-10T19:05:06+00:00

I can create a number by doing var n1 = 1; or var n1

  • 0

I can create a number by doing

var n1 = 1;

or

var n1 = Number(1);

same with a string

var s1 = 'string1';

or

var s1 = String('string1');

In what cases would one want to use the Global Object as opposed to the simpler way.

Do the JavaScript Global Objects String and Number have any use when programming?

Similarly for

Regexp, Boolean, Function

Is there any purpose for these which can all be instantiated using the appropriate syntax instead?

  • 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-10T19:05:08+00:00Added an answer on June 10, 2026 at 7:05 pm

    Having them available allows us to extend them. For example, if the browsers don’t implement it, you can add the Array.isArray method yourself.

    Array.isArray = function( arr ) {
        return Object.prototype.toString.apply( arr ) === '[object Array]';
    };
    

    This is good to have for most polyfills.

    Another nice example is the trim method on strings.

    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,'');
    };
    

    Otherwise, there isn’t really other uses. Converting to a number is better done with +, converting to a string is better done with '' +, etc.

    The only one I regularly use is Regexp though, as it’s convenient to do new Regexp (for saving in a variable, because less escaping is needed or because it allows to break up the regex in multiple lines).

    Edit: I just thought about another use:

    arr.filter( Boolean ); // Removes falsy values from the array "arr"
    arr.map( Number ); // Converts every element of the array to a Number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There seem to be a number of different ways in which one can create
How can I create a date object which is less than n number of
Hi I have the following requirement. I want to create variable number of String
Can anyone show me how to create a mathematical expression for the number of
I can create and use dynamic two dimensional array in Fortran (in 77 standard).
How can create a string in JSON after a mysql select: $ritorno = '{Prodotto:'.$riga['Prodotto'].',Prezzo:'.$riga['Prezzo'].'}'
A Party can have one or more Contact objects. I want to select all
You can create a table model and add it to a table TableModel tm
I can create database manually by going to cpanel. But I'd like to create
I can create a contact that is not mail enabled, but how do I

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.