get specific value from object in javascript [closed]

i need to get an value from an object given below, Here i need to get “value” from below object,

var a = { 'getData': [ { title: 'posted By', value: '18th Sep' } 
 ] };

here i am trying like a.'getData'[0].value;

here i need to print the value ’18th sep’

Answer

The expression a.'getData'[0].value is not valid JavaScript syntax.

You can simply access the required value using standard dot notation, e.g.

a.getData[0].value.

Or you could use bracket notation if you wished, e.g.

a['getData'][0]['value']

var a = { 'getData': [ { title: 'posted By', value: '18th Sep' } ] };
console.log('Value (dot notation):', a.getData[0].value);   
console.log('Value (bracket notation):',a['getData'][0]['value']);