JSFiddle - React, Tailwind, and code Playground
by lavisha99
JavaScript
//Object members
//see first code log
//object literal
/*
var dog= {
name:'spot'
breed:'dalmatian'
};
Objects --> values and functions vs state and behaviour vs properties and methods.
L7.1
Objects Members
The properties and methods of an objrct are often valled the object members of object services
solve the problem through the services of the obhject
Object properties can be primitive or non primitive
*/
//the keyword this is used to reference the values properties of the code.
person = {
name: ['Bob','Smith'],
age: 32,
gender: 'male',
interests:['music','skiing'],
displayBio: function () {
alert(this.name) + alert(this.name[1])+ 'is'+this.age +' old'
}
}
console.log(person.name);
//access a method member of an object
person.displayBio()
//at this stage there is no object, it is just a template/class
function weapon(name, sound) {
this.name = name;
this.sound = function() {
alert(sound);
}
}
}