Skip to content

Instantly share code, notes, and snippets.

@robynitp
Last active August 29, 2015 13:57
Show Gist options
  • Save robynitp/9652665 to your computer and use it in GitHub Desktop.
Save robynitp/9652665 to your computer and use it in GitHub Desktop.
A basic Javascript object literal
var employee = {
name: 'Jane',
dob: '04-09-80',
position: 'Art Director',
start_date: '10-14-2011',
subordinates: ['Jack','Jill','Edward'],
work: function(){
console.log('I make stuff');
},
employee_id: 23452
};
// output the employee's name
alert(employee.name);
// call the function that's stored in the work property
employee.work();
// output all the names in the subordinates array
for (var i=0;i<employee.subordinates.length;i++){
console.log(employee.subordinates[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment