i want to learn javascript object, i spend time on the internet and learn about the javascript object a bit and i am confused what is use of object and how to build your own object in javascript. i also see some javascript function in which they use their own custom object. i have some code for example.
var animationSections = {
'intro': 0,
'over': 200,
'around': 1600,
'through': 3500,
'share': 5000
};
i copy above given code from one javascript file it is for animation and they use this object.
startAt: 0+animationSections.over
now my question will come up why we use animationSections.over rather we can use ‘200’
It would be good to have some object oriented programming background.So you can understand much more better here.An OBJECT has a property.In this animationsector is an Object.Instead of saying 200 directly, represent it via Object.property mechanism.This will make your code much more cleaner and easy to maintain.Also, after sometime, when you revisit the code after sometime, it will be bit difficult to remember or map why 200 is used.But instead, if maintain an object and say ‘over’, then you can be able to identify its significance.it represents the context.Hope this will help you.