DEV Community

_Khojiakbar_
_Khojiakbar_

Posted on • Edited on

1

Object methods 🦜

let result;
const userProfile = {
        username: 'Khojiakbar',
        age: 26,
        job: 'programmer',
        city: 'Tashkent region',
}
Enter fullscreen mode Exit fullscreen mode

// Object.keys()
result = Object.keys(userProfile);

// Object.values()
result = Object.values(userProfile);

// Object.entries()
result = Object.entries(userProfile) // returning nested array

// Object.fromEntries()
let fromEntries = Object.fromEntries(result)

console.log(result);
console.log(fromEntries);
Enter fullscreen mode Exit fullscreen mode
// Object.freeze()
Object.freeze(userProfile);

// Add -
userProfile.weight = 80
// Modify -
userProfile.username = 'Bilol'
// Delete -
delete userProfile.city
// NO AMD
console.log(userProfile);
Enter fullscreen mode Exit fullscreen mode
// Object.isFrozen()
result = Object.isFrozen(userProfile)
console.log(result);
Enter fullscreen mode Exit fullscreen mode
// Object.seal()
result = Object.seal(userProfile);

// Add -
userProfile.weight = 80;
// Modify +
userProfile.age = 33;
// Delete -
delete userProfile.city;
// NO AD
console.log(userProfile);
Enter fullscreen mode Exit fullscreen mode
// Object.isSealed()
result = Object.isSealed(userProfile)
console.log(result);
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay