Javascript Node Js basic to Advance
Ir al canal en Telegram
Javascript Node Js group @LogicB_Support @BCA_MCA_BTECH
Mostrar más1 176
Suscriptores
Sin datos24 horas
-27 días
-1130 días
Archivo de publicaciones
// 18. Object.fromEntries()
let entries = [['a', 1], ['b', 2], ['c', 3]];
let newObject = Object.fromEntries(entries);
console.log(newObject);// 17. Object.entries()
let sampleObject = { a: 'Apple', b: 'Ball', c: 'Cat' };
let entries = Object.entries(sampleObject);
console.log(entries);// 16. Object.is()
let value1 = 5;
let value2 = 5;
console.log(Object.is(value1, value2));// 15. Object.setPrototypeOf()
let sampleObject = {};
let prototypeObject = { prototypeProp: 'prototype' };
Object.setPrototypeOf(sampleObject, prototypeObject);
console.log(sampleObject.prototypeProp);// 14. Object.getOwnPropertyDescriptors()
let sampleObject = { name: 'John', age: 30 };
let descriptors = Object.getOwnPropertyDescriptors(sampleObject);
console.log(descriptors);// 13. Object.defineProperties()
let sampleObject = {};
Object.defineProperties(sampleObject, {
property1: {
value: 42,
writable: true
},
property2: {
value: 'Hello',
writable: false
}
});
console.log(sampleObject.property1);
console.log(sampleObject.property2);// 12. Object.defineProperty()
let sampleObject = {};
Object.defineProperty(sampleObject, 'property1', {
value: 42,
writable: false
});
console.log(sampleObject.property1);// 11. Object.create()
let sampleObject = { name: 'John', age: 30 };
let newObject = Object.create(sampleObject);
console.log(newObject);// 10. Object.hasOwnProperty()
let sampleObject = { name: 'John', age: 30 };
console.log(sampleObject.hasOwnProperty('age'));// 9. Object.getPrototypeOf()
let sampleObject = {};
console.log(Object.getPrototypeOf(sampleObject));// 8. Object.getOwnPropertyNames()
let sampleObject = { name: 'John', age: 30 };
console.log(Object.getOwnPropertyNames(sampleObject));// 7. Object.getOwnPropertyDescriptor()
let sampleObject = { name: 'John', age: 30 };
let descriptor = Object.getOwnPropertyDescriptor(sampleObject, 'age');
console.log(descriptor);// 6. Object.seal()
let sampleObject = { name: 'John', age: 30 };
Object.seal(sampleObject);
// Attempting to add/delete properties in a sealed object's descriptor will not work// 5. Object.freeze()
let sampleObject = { name: 'John', age: 30 };
Object.freeze(sampleObject);
// Attempting to modify a frozen object will not work// 4. Object.assign()
let obj1 = { a: 1, b: 2 };
let obj2 = { b: 4, c: 5 };
let mergedObject = Object.assign({}, obj1, obj2);
console.log(mergedObject);// 3. Object.entries()
let sampleObject = { name: 'John', age: 30, city: 'New York' };
console.log(Object.entries(sampleObject));// 2. Object.values()
let sampleObject = { name: 'John', age: 30, city: 'New York' };
console.log(Object.values(sampleObject));// 1. Object.keys()
let sampleObject = { name: 'John', age: 30, city: 'New York' };
console.log(Object.keys(sampleObject));