JavaScript

Object.keys, values, entries

Në shqip: Metodat e Object-it

ShpjegimiSQ

Object.keys() të jep emrat e vetive të një objekti, Object.values() vlerat, dhe Object.entries() çiftet [çelës, vlerë]. Janë mënyra si kalon me cikël nëpër një objekt, ose e kthen në varg për të përdorur map dhe filter.

EnglishEN

Object.keys() gives you an object's property names, Object.values() the values, and Object.entries() the [key, value] pairs. They're how you loop over an object, or turn it into an array to use map and filter.

Si ta mendosh

Si ta shohësh listën e kontakteve vetëm me emra, vetëm me numra, ose me të dyja bashkë.

Lexoje në anglisht

Like viewing your contacts as names only, numbers only, or both together.

Shembull kodijavascript

const notat = { Arta: 5, Dren: 4 };
Object.keys(notat);     // ["Arta", "Dren"]
for (const [emri, nota] of Object.entries(notat)) {
  console.log(emri, nota);
}

Terma të lidhur