-1

In Javascript, objects 'window' and 'document' start with a small letter, but global object 'Math' starts with a capital object.

Do these objects follow a standardised naming convention?

2 Answers2

1

In Javascript, objects 'window' and 'document' start with a small letter, but global object 'Math' starts with a capital object.

Math is "in JavaScript." The other two are browser-specified, not part of JavaScript.

Do these objects follow a standardised naming convention?

The JavaScript ones do (a convention followed by the specification, that is; programmers are free to do their own thing elsewhere): Constructor functions (like Date) and objects whose primary purpose is to host utility functions (like Math) are initially-capped can CamelCase. Other functions are lower-case camelCase. Symbol is also capped; it creates things (symbols, which are primitives) although you don't call it via new (because symbols are primitives).

Browser global objects referring to specific things (like window and document) have tended to follow the lower-case camelCase convention for variables which is common in JavaScript. And browser-defined constructors like XMLHttpRequest have tended to match JavaScript's CamelCase for such things as well. (In both cases, I wouldn't be surprised to find exceptions; much of this stuff happened organically rather than by overall design.)

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
-2

These are all built-in JS objects. So we have to follow the conventions.

pc.97
  • 153
  • 1
  • 4
  • 12
  • Is this a piece of the art of English language, or just nonsense ..? – Teemu Dec 07 '17 at 13:08
  • @Teemu can you ellaborate your question here – pc.97 Dec 07 '17 at 15:53
  • As far as I can understand your answer, it's pure nonsense, but I'm not that good in English, so there might be something I haven't understood. – Teemu Dec 07 '17 at 15:55
  • what do you find nonsense ? I think your English is quite good. – pc.97 Dec 07 '17 at 15:57
  • I think you downvoted the answer. That is fine. You can tell me the right answer to the question. – pc.97 Dec 07 '17 at 16:13
  • No, I didn't, because I'm not sure what it says. T.J.Crowder seems to has written the correct answer already, I've no additional information to T.J.'s answer. – Teemu Dec 07 '17 at 16:51