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?
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?
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.)
These are all built-in JS objects. So we have to follow the conventions.