Snippets Collections
const person = {
  firstName: "John",
  lastName: "Doe",
  age: 30,
  isEmployed: true,
  hobbies: ["reading", "traveling", "coding"],
  address: {
    street: "123 Main St",
    city: "Anytown",
    country: "USA",
  },
  greet: function () {
    return `Hello, my name is ${this.firstName} ${this.lastName}.`;
  },
};

const newObj = {};

for (let key in person) {
  if (key === "firstName" || key === "lastName") {
    newObj[key] = person[key];
  }
}

console.log({ newObj });
const person = {
  key: "value",
  first_name: "John",
  last_name: "Doe"
};

Object.keys(person);
month_conversion = {
“Jan” = “January”
“Feb” = “February”
“Mar” = “March”
“Apr” = “April”
“Jun” = “June”
}
# keys must be unique:
print(month_conversion[“Mar”])


Output”
           March
star

Wed Dec 25 2024 22:47:37 GMT+0000 (Coordinated Universal Time)

#oop #keys #loop
star

Wed Apr 05 2023 15:59:14 GMT+0000 (Coordinated Universal Time) https://codetogo.io/

#javascript #keys #object
star

Mon Mar 30 2020 12:10:17 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/watch?v=rfscVS0vtbw&t=5s

#python #python #dictionary #keys

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension