- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript fetch a specific value with eval()?
The eval() is used to evaluate an argument in JavaScript. Following is the syntax −
eval(str)
Here, str can be an expression, variable or statement(s).
Let’s say the following is our array −
var studentMarks = [76,34,56,78,81,98,90,59,64];
Now, fetch a specific value with eval(). Here, we are fetching the value at index 1 −
Example
var studentMarks = [76,34,56,78,81,98,90,59,64]; var stringValue = eval("studentMarks"); console.log(stringValue[1]);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo80.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo80.js 34
- Related Articles
- MongoDB aggregation to fetch documents with specific field value?
- Fetch a specific column value (name) in MySQL
- Match MongoDB documents with field value greater than a specific number and fetch them?
- Fetch values by ignoring a specific one in JavaScript?
- Fetch the value for a specific key in Java IdentityHashMap
- Query an array in MongoDB to fetch a specific value
- PHP fetch a specific value that begins with a given number from a string with letters and numbers?
- How to query MongoDB a value with $lte, $in and $not to fetch specific values?
- MongoDB query to fetch a specific document rom documents with field value set using NumberInt()?
- Fetch a specific document in MongoDB with array elements
- eval() function in JavaScript
- Fetch data between two dates and with a specific value in MongoDB. Group and get the sum with count?
- Fetch specific values from array of objects in JavaScript?
- Fetch specific documents with array values in MongoD
- Fetch specific rows from a MySQL table with duplicate column values (names)?

Advertisements