Object.keys(obj) - returns an arrays of keys.
syntax:
let array1 = Object.keys(object)
Note: The argument is an object. The Object.keys() method will return all the keys inside the object that you specify in an array form.
==================
let book1 = {
title: "Reincarnated as a Slime",
author: "Rimuru Senpai",
published: 2021
};
function displayTheBook1(){
let array1 = Object.keys(book1);
document.writeln(array1);
}
==================
Result:
name,author,published
Note: In the tutorial, there are Object.values and Object.entries but when I tried to used it, it is not allowed. There is no such thing as those. Maybe because it was deprecated.
YOU ARE READING
Javascript Programming
RandomI am just documenting things what i learned online in here. I do express things in my own words. And I create my own program samples which serves as my practice. I do this so that when someday I would need some notes to review, I can just visit in h...
