Normalization

1st normal form

Remove duplicate data and break data at a granular level, as if a column has cities files: it should be brake into the different column or should maintain the different table

2nd normal form

All column data should  depend on full primary key and not part of key

3rd normal form

No column should depend on other columns and it shouldn’t have calculated values

JavaScript object and prototype

JavaScript Object and prototype:

These two different codes will produce the same output

var cat = {name: 'Fluffy'}

var cat = Object.create(Object.prototype, { 
 name: { 
  value: "Fluffy", 
  enumerable: true, 
  writable: true, 
  configurable: true
 }
});

Follow the below code to get the same output, and the same can be configured


Object.getOwnPropertyDescriptor(cat, 'name')

Object.defineProperty(cat, 'name', {writable: false})
Object.defineProperty(cat, 'name', {enumerable: false})

Object.keys(cat)

Object.defineProperty(cat, 'fullName', 
{
 get: function () { return this.name.first + ' ' + this.name.last},
 set: function () {
  var nameParts = values.split(' ');
  this.name.first = nameParts[0];
  this.name.last = nameParts[1];
 }
})

var arr = ['aa', 'bb']
Object.defineProperty(arr, 'last', { get: function () {return this[this.lenght-1]}})

Object.defineProperty(Array.prototype, 'last', { get: function () {return this[this.lenght-1]}})

var last = arr.last

---
function Cat (name, color)  {
 this.name = name;
 this.color = color
}

var fluffy = new Cat('fluffy', 'white')
Cat.prototype
fluffy.__proto__

var muffine = new Cat('Muffin', 'Brown')
muffine.__proto__

fluffy.age = 5
fluffy.age
fluffy.__proto__.age

Object.keys(fluffy)
fluffy.hadOwnProperty('age')
fluffy.hadOwnProperty('color')