in javscript
I can't able to fetch value from a object.
When printing whole object is printing. But, when I am trying to access only 1 field it is showing error
function add_new_row()
{
let gg =
{
"1st_col" : '99',
"2nd_col" : '88',
"3rd_col" : ['77', '66'],
"4th_col" : '55',
}
console.log(gg); //{1st_col: "99", 2nd_col: "88", 3rd_col: Array(2), 4th_col: "55"}
console.log(gg.1st_col); //Error here
//this is the line where I called this function in button HTML
}
The error that is thrown is:
Uncaught ReferenceError: add_new_row is not defined
at HTMLInputElement.onclick (index2.html:120)
onclick @ index2.html:120
console.log(gg.1st_col);
to throwUncaught ReferenceError: add_new_row is not defined
.console.log(gg["1st_col"]);
You can check the MDN for valid identificators when using dot notation...