Advertisement
Justman10000

JavaScript Coding

Sep 4th, 2023
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Basic
  2. # Advanced
  3. # Expert
  4. ## Reading keys and their values from an object
  5. const object = {
  6.     "key": "value",
  7.     "key2": "value2",
  8. }
  9.  
  10. for (const key in object) {
  11.   if (object.hasOwnProperty(key)) {
  12.     const value = object[key];
  13.  
  14.     console.log("Key:", key);
  15.     console.log("Value:", value);
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement