Defining Read Only Properties in JavaScript | JavaScript Objects Tutorial

Publicado em: 05 Abril 2018
no canal de: dcode
2,723
45

By using the Object.defineProperty method you are able to define properties as 'read only' in JavaScript - this is done by setting the 'writable' property to 'true' while defining the property.

In this video I go over how to do this with a simple example of an object literal representing a Person. Using the 'defineProperty' method I define a new property called 'born' which will describe where the Person was born - and since you can't really change where you were born, we will be defining this as a 'read only' property - you can't change it!

For your reference, check this out:
https://developer.mozilla.org/en-US/d...

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!


Nesta página do site você pode assistir ao vídeo on-line Defining Read Only Properties in JavaScript | JavaScript Objects Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário dcode 05 Abril 2018, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 2,723 vezes e gostou 45 espectadores. Boa visualização!