JavaScript
Objects in JavaScript
Objects In JavaScript
An object is a collection of properties, and a property is an association between a name (Or key) and a value. A property`s value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects.
var a = {
fname : 'product',
lname : "one",
age : 25,
email : 'ramesh@gmail.com',
}
// document.write(a);
// console.log(a);
console.log(a.email);
Assign array[] in Objects, here you can see the example
var a = {
fname : 'product',
lname : "one",
age : 25,
email : 'rameshj@gmail.com',
movies : ['movieOne','movieTwo','movieThree']
}
// document.write(a);
// console.log(a);
// console.log(a.email);
console.log(a.movies);
Assign functions() in Objects, here you can see the example
var a = {
fname : 'product',
lname : "one",
age : 25,
email : 'ramesh@gmail.com',
movies : ['movieOne','movieTwo','movieThree'],
salary : function(){
return 25000;
}
}
// document.write(a);
// console.log(a);
// console.log(a.email);
// console.log(a.movies);
console.log(a.salary());