1: Two syntax for declaring objects

let obj = { 'name': 'frank', 'age': 18 }

let obj = new Object({'name': 'frank'})

console.log({ 'name': 'frank, 'age': 18 })

Note: key is a string without a numeric key

2: How to delete object attributes

Delete obj. XXX or delete obj[‘ XXX ‘]

3: How to view the properties of an object

View all of your properties:

Object.keys(obj)

View self + Common properties:

Console. dir(obj) or print obj.__proto__ with object. keys yourself

View a property:

  • Bracketed syntax:obj['key']
  • Some grammar:obj.key

4: How to modify or add object attributes

  • Direct assignment

Let obj = {name: ‘frank’} name is a string

Obj. name = ‘frank’ Name is a string

obj['name'] = 'frank'

obj['na'+'me'] = 'frank'

let key = 'name'; obj[key] = 'frank'

  • Batch assignment

Object.assign(obj, {age: 18, gender: 'man'})

5: difference between ‘name’ in obj and obj.hasOwnProperty(‘name’

‘name’ in obj cannot confirm whether the property is its own or common to the stereotype. Obj. hasOwnProperty(‘name’) confirms whether the property is its own