 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get only the first BOT ID from thes JavaScript array?
Let’s say we have records with BOTID and Name of assigned users −
let objectArray = [    { BOTID: "56", Name: "John" },    { BOTID: "57", Name: "David" },    { BOTID: "58", Name: "Sam"},    { BOTID: "59", Name: "Mike" },    { BOTID: "60", Name: "Bob" } ]; We know the array starts from index 0. If you want to access the first element from the above array, use the below syntax −
var anyVariableName=yourArrayObjectName[index].yourFieldName;
Example
let objectArray = [    { BOTID: "56", Name: "John" },    { BOTID: "57", Name: "David" },    { BOTID: "58", Name: "Sam"},    { BOTID: "59", Name: "Mike" },    { BOTID: "60", Name: "Bob" } ]; const output = objectArray[0].BOTID; console.log(output); To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo49.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo49.js 56
Advertisements
 