O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

objects

milly larcen Object Inglês 2 flashcards

Flashcards do conjunto (2)

  1. 1way to check if an object has a propertyconst user = { name: 'Olivier',}
    'name' in user // true
    in operator checks if the property is in the specified object or its prototype chain, so 'constructor' in user // true
    hasOwnProperty method indicates if the object has the specified property as its own property.
    myObject.hasOwnProperty('id')
    It is recommended to use: Object.prototype.hasOwnProperty.call(myObject, 'id') instead
    What is the difference and why should you use the second syntax ?
    1
    You can create objects without any prototype in javascript this way:
    const myObject = Object.create(null). Why would you do that instead of const myObject = {}?
    Because it was apparently a way to simulate a map data structure (you would still get an object but without any properties or methods inherited from the prototype) before they introduce the Map data structure.
    2
    u can overwrite the hasOwnProperty method (or any other method) and thus:
    const user = { name: 'Olivier' }
    user.hasOwnProperty = null
    user.hasOwnProperty('name') // Uncaught TypeError
    Object.prototype.hasOwnProperty.call(user, 'name') // true
  2. 2destructuringvar obj ={color: "blue"}
    console.log(obj.color);
    ***
    var { color, name} = { color: "blue", name: "John", city: "NY"}
    console.log(color);

Informações

Descrição
Object FlashCards sobre objects, criado por milly larcen em 16-04-2020.
Criado por
milly larcen
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?