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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:13:00+00:00 2026-06-17T08:13:00+00:00

I am somewhat new to JavaScript and I have a question. I know you

  • 0

I am somewhat new to JavaScript and I have a question.

I know you can set variables and “sub-variables”. Like:

var msg = "Hello World";
alert(msg);

and also

var msg = {
    lipsum: "Lorem Ipsum Dolor Sit Amet"
}
alert(msg.lipsum);

But I was wondering if you could do both, like

var msg = "Hello World" || {
    lipsum: "Lorem Ipsum"
}
alert(msg + msg.lipsum);

That way, you can declare a variable and also have the same variable be an object. Obviously it couldn’t be done with what I did, but you get the picture.

Any help would be much appreciated!

  • 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-17T08:13:01+00:00Added an answer on June 17, 2026 at 8:13 am

    Actually, you can.

    var msg = {
        lipsum: "Lorem Ipsum",
        toString: function() {return "Hello World!"}
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript file which has some code somewhat like this: var Slide
I'm somewhat new to Javascript and I can't seem to figure out exactly what's
I am somewhat new to LINQ and have a quick question regarding deleting. Say,
I have the following javascript object, somewhat pseudocode: { dateField: new Date(), addMinutes:function(numMinutes) {
I'm somewhat new to Javascript, not HTML/CSS or PHP/MySQL, just JS. I have a
I'm somewhat new to jQuery/javascript, and would like to compare the contents of row[i]
I somewhat new to Javascript and I'm stuck on this one item. Can someone
So I am still somewhat new to PHP, MySQL, and Javascript but I have
I have a utility class that makes Python dictionaries behave somewhat like JavaScript objects
I am somewhat new to JavaScript, and have been having an issue with a

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.