Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do primitive type names need to be uppercase or lowercase?

Tags:

jsdoc

jsdoc3

/**
 * @param {String} foo
 * @param {Number} bar
 */

or

/**
 * @param {string} foo
 * @param {number} bar
 */

JSDoc @type documentation is not being explicit about it.

I always uppercase String and Number because it is my understanding that I need to use the constructor name. In JavaScript, String and Number exist as constructors.

I have noticed inconsistency: I am defining other primitive types (e.g. null, undefined) as lowercase.

Do primitive type names need to be uppercase or lowercase?

like image 904
Gajus Avatar asked Sep 29 '15 14:09

Gajus


People also ask

Should typescript types be uppercase?

Typescript doesn't care, so follow the conventions of your project. If you're starting a new project, most Javascript devs use capitalized words for classes, and since type aliases are conceptually similar to classes, I'd say capitalize them too. But the compiler doesn't care in the slightest.

Is double uppercase or lowercase Java?

java - Types like int, double, char, long, float all start with lowercase letter, except String type.

Which statement is true about primitives?

All the primitive types are lowercase, making Option A correct. Unlike object reference variables, primitives cannot reference null. String is not a primitive as evidenced by the uppercase letter in the name and the fact that we can call methods on it. You can create your own classes, but not primitives.

Why does the type string have a capital letter?

because it is a class, and it is common programming style to make the first letter of a class uppercase.


1 Answers

It doesn't matter:

JSDoc doesn't care. It's up to the user's preference. I tend to use lowercase for primitive types (and function, for some reason) and uppercase for Array and Object.

I tend to use lowercase because the typeof operator returns lowercase.

like image 71
chib Avatar answered Oct 05 '22 02:10

chib