By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

Date v Math as Instance v Static

P: n/a
Howdy All!

I am trying to write a very brief comparison of the Date and Math objects in
terms of instance v static objects. What I have below is my best so far. Any
criticisms or suggestions are most welcome!

Date is an instance object.
You use Date by creating instances of it
- you call methods on those instances.
- you change data to do with each instance.
Instance objects store state
- meaning they hold data that may change over time.

Math is a static object.
You never create instances of it
- you call methods on Math directly.
- it never stores data for you: each method performs some mathematical
computation and returns a result. It is up to you to store required data.
Static objects can store state - but Math does not.

Rob
:)
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> I am trying to write a very brief comparison of the Date and Math objects in
terms of instance v static objects. What I have below is my best so far. Any
criticisms or suggestions are most welcome!

Date is an instance object.
You use Date by creating instances of it
- you call methods on those instances.
- you change data to do with each instance.
Instance objects store state
- meaning they hold data that may change over time.

Math is a static object.
You never create instances of it
- you call methods on Math directly.
- it never stores data for you: each method performs some mathematical
computation and returns a result. It is up to you to store required data.
Static objects can store state - but Math does not.


Date is a constructor function. Functions are objects, so it can act as a
container of [static] functions.

Math is not a function, it is just an object. It acts as a container for a
collection of functions.

http://www.crockford.com/#javascript

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.