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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:20:32+00:00 2026-06-01T04:20:32+00:00

var data = {}; …. data[someprop][someotherprop] = ‘bla bla’ I get Uncaught TypeError: Cannot

  • 0
var data = {};


....

data[someprop][someotherprop] = 'bla bla'

I get

Uncaught TypeError: Cannot read property ... of undefined and Cannot set property of...

Yes, the object doesn’t have these properties ..yet, but I’m setting them in that line where I get the error lol. So what’s up with that?

  • 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-01T04:20:34+00:00Added an answer on June 1, 2026 at 4:20 am

    if someprop and someotherprop are variables, Richard D’s answer is correct, if they are hardcoded strings, you could write your code like this:

    var data = {someprop:{someotherprop: 'value'}};
    

    if, however, they are values stored in variables, and you really – really want to cram everything into a single line, try something like this:

    var data = {window.someprop : {window.someotherprop: 'value'}};
    

    where window can be replaced by any object, if the someprop value is itself a property of an object:

    var data = {someForm.name : { formElement.name : formElement.value}};
    

    Or jQuery objects, since your tag suggest you’re using jQuery:

    var data= {$('#formId').attr('name'):{$('#formSelect').attr('name'): $('#formSelect').val()}};
    

    Note: the jQuery example is not to be recommended, as the id selector is used twice on the same element. jQuery will scan the DOM-tree twice, so you’re better of storing your that #formSelect element in a variable somewhere.

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

Sidebar

Related Questions

I'm using: var data = $(form :input[value]); To get all the values in a
var data = $(#list2 li).map(function () { return $(this).children().html(); }).get(); the data variable contains
$('#submit').click(function () { //Get the data from all the fields var name = $('input[name=name]');
function getsession(){ var data = $.get('../session', function(data) { return data; }); return data; }
How can I get some var / data from a custom classes? The XML
var data = <div><table width='100%'><tr><td align='right' ><div class='close16'/></td></tr></table><div><table><tr><td rowspan='4' width='50px;'><img src=' + staffItem.Photo +
If I have HTML content in a variable like so: var data = <div
I have a piece of javascript code as follows: var data = { ...
My flash code: var request=new URLRequest('http://localhost/test.php'); request.method = URLRequestMethod.POST; var data = new URLVariables();
Code example: <script> var data = new Array(); data[0] = 'hi'; data[1] = 'bye';

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.