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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:20:45+00:00 2026-05-29T04:20:45+00:00

What is the difference between the code (i) and (ii) written below ? (i)

  • 0

What is the difference between the code (i) and (ii) written below ?

(i)

var obj:Object = new Object();
obj.attribute = value ;

(ii)

var obj:Object = new Object();
obj["key"] = value;

Are there any run-time implications if I write this :

var obj:Object = new Object();
obj.somekey = value1 ;
obj["someKey"] = value2 ;

Please explain.

  • 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-29T04:20:48+00:00Added an answer on May 29, 2026 at 4:20 am

    The difference is in the lookup mechanism: If you use the dot syntax, the compiler will know at compile time that you are accessing a property of that object. If you use the bracket syntax, the actual lookup of the property is done at runtime, and there will have to be more type checking – after all, you could compose the key string dynamically, the value could change, or you could even be calling a function instead of a variable, etc.

    The result is a significant difference in performance: Bracket syntax takes about three times as long to execute as dot syntax.

    Here’s a little speed test to illustrate my point:

    var start : int = getTimer();
    
    var obj:Object = { something : "something" };
    
    for (var i : int = 0; i < 100000000; i++) {
        var n:String = obj.something;
    }
    
    trace ("Time with dot syntax: "+(getTimer() - start));
    
    start = getTimer();
    
    for (i = 0; i < 100000000; i++) {
        var o:String = obj["something"];
    }
    
    trace ("Time with bracket syntax: "+(getTimer() - start));
    

    If the two were the same, except for notation, they should take exactly the same amount of time. But as you can see, this is not the case. On my machine:

    Time with dot syntax:      3937
    Time with bracket syntax:  9857
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
Is there any difference between these tow pieces of code & which approach is
What is the difference between object code, machine code and assembly code? Can you
What's the difference between the two code below. int a[] = {0,0}; int a[2]
I have been told that there is a performance difference between the following code
What is the difference between the following two snippets of code: using (Object o
Is there any difference writing the code in normal php and php in codeigniter.
I have code to calculate the percentage difference between 2 numbers - (oldNum -
What is the difference between these two pieces of code type IInterface1 = interface
What is the difference between the concepts of Code Re-entrancy and Thread Safety ?

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.