Hi Friends đź‘‹,
Welcome to Infinitbility ❤️!
Today, we will learn how to get value from an object by key in typescript, here we will use some basic syntax to get value from an object.
Here, we will see
- Access object value using the dot method
- Access object value using bracket method ( we can also use it for dynamic value access )
In the code below, we create a sample object variable to store sample dog data.
after creation, I use variables to access the object values.
Let’s dive into code…
1// create sample object variable2const animals = {3 id: 1,4 name: "dog",5 age: 56};78// access value by dot syntax9animals.id;1011// access value by bracket ( we can also use it for dynamic value access )12animals["name"]
When you run the above code, you will get the id
and name
keys value. For now, let’s check the output.

All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.