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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:39:29+00:00 2026-06-12T00:39:29+00:00

Watching a tutorial today I came across the following: var q2Var1 = hi there.,

  • 0

Watching a tutorial today I came across the following:

var q2Var1 = "hi there.",
    q2Var2 = String( "another string here." );

Is q2Var the “constructor notation” and q2Var the “literal notation” for declaring a variable, or am I not drawing the correct conclusion?

Thank you.

  • 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-12T00:39:31+00:00Added an answer on June 12, 2026 at 12:39 am

    No, neither of those use a constructor to create a string object.

    The first is just a string primitive, the second is a string primitive that is sent through the String conversion function, which will just return the string primitive unchanged.


    The String conversion function is usually used to turn other things into string primitives, for example a number:

    var s = String(42);
    

    To create a String object you use the new keyword:

    var s = new String("hi there.");
    

    The String object has all the methods that you are used to use on a string, like the length property. The reason that you can use them on string primitives also, is that they are automatically converted to String objects when you use a method on them.

    So, this:

    var l = "asdf".length;
    

    actually does the same as:

    var l = new String("asdf").length;
    

    The String conversion function always returns a string primitive, so if you have a String object, the function will turn it back into a string primitive:

    var s = "asdf"; // typeof s returns "string"
    
    var s = new String(s); // typeof s now returns "object"
    
    s = String(s); // typeof s now returns "string"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was watching a Silverlight tutorial video, and I came across an unfamiliar expression
I found the following table structures while I was watching ruby on rails tutorial.
Hey guys I'm following the rails tutorial found here http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I've gotten to
I'm trying RubyMine, and watching this tutorial https://www.jetbrains.com/ruby/documentation/ . The author uses there project->new->scaffold
I was watching a tutorial series on PHP MySQLi this morning and I came
A question cropped up while watching a tutorial video. Are there any rules regarding
ive been watching a tutorial that has told me to change the background color
I'am watching some video tutorial about css and find realy strange thing. First of
I'm new to rails, and I'm watching this video tutorial online and I was
I'm currently watching Mule 101: Demonstrations of all things Mule tutorial because I was

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.