What does this record?

Hello. There is a json object.
As I understand it iterates through the properties. How to treat "prop" to "data.yandex"?

Object.keys(data.yandex).forEach(function(prop) { 
 $yanfexForm.find('input[name="' + prop + '"]').val(data.yandex[prop]) 
})
June 10th 19 at 16:33
3 answers
June 10th 19 at 16:35
Solution
propis a properties that are object data.yandex

Read more: https://www.w3schools.com/js/js_arrays.asp item Associative Arrays
Technically it is an associative array where instead of a numeric index can be something else, e.g. just a string. But in JS is represented by object that consists of data with named indexes
June 10th 19 at 16:37
Solution
data.yandex is an object. Object has no method forEach, I have it in the array. So we get an array of the keys of an object using Object.keys, and run the cycle. And inside the loop we already apply directly to a particular object key data.index.
here's an example:

const data = {yandex: { popka: 'popka value', durak: 'durak ' value' }}
// => undefined
Object.keys(data.yandex)
// => Array [ "popka", "durak" ]
Object.keys(data.yandex).forEach(function(key){
 console.log(data.yandex[key]) // will return the first value then popka durak value
})


How to treat "prop" to "data.yandex"?

common. incorrect variable name. The correct name would be key , then, to read the code will be clearer, and it becomes clear without hesitation, that key is the key of the object data.yandex
June 10th 19 at 16:39
the name of the properties

Find more questions by tags jQueryJavaScript