Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
var i = "test"; var test1 = { test: 3, b: 3 }; console.log(test1.i);
Sorry if it's a simple answer, I am still learning.
var i is looping to something different every few seconds and var i will always be something on test1.
console.log(test1[i])
If you are trying to retrieve a property of an object you can use the . notation, or the [] notation
.
[]
var test1 = { test: 3, b: 3 };
Using . notation
test1.test; // -> returns 3
Using [] notation
var propertyName = 'test' test1[propertyName]; // -> returns 3
Add a comment
Do it this way:
var test1 = { test : 3 }; console.log(test1[i])
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
console.log(test1[i]).