Javascript - How To Create a Basic Javascript Object and Access Its Properties

Publié le: 12 mars 2015
sur la chaîne: A Tech Apart
1,527
10

an object creates a model by grouping together a set of related variables, values and functions

an object's properties can use different value types e.g. string, number, boolean, array and even functions (if a property's value is a function, it is called a method), it can even contain other objects

you can access an object's properties using dot notation, most commonly used because it's easier to use and easier on the eyes

you can also access an object's properties using bracket notation, although less commonly used, it has a couple of advantages over dot notation
-bracket notation is the only way to access property or method names that don't follow variable naming rules (e.g. a property name like "another key" has a space inbetween)
-with bracket notation you can also access an object's property using string concatenation, although not entirely recommended

if you try to access a property that doesn't exist, undefined will be returned

   • Javascript - How to Access Javascript Obje...   - Javascript - How to Access Javascript Object Property Names Using Object.keys()

   • Javascript - How to Access Javascript Obje...   - Javascript - How to Access Javascript Object Property Names Using A for in LOOP

----------------
resources:

http://stackoverflow.com/questions/49...

-----------------------------------------------------------
http://atechapart.com |   / alvinsanchez  

see my codepens @ http://codepen.io/_asanchez/


Sur cette page du site, vous pouvez voir la vidéo en ligne Javascript - How To Create a Basic Javascript Object and Access Its Properties durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur A Tech Apart 12 mars 2015, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,527 fois et il a aimé 10 téléspectateurs. Bon visionnage!