Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 565 Bytes

constants.md

File metadata and controls

31 lines (21 loc) · 565 Bytes

Constants

Constants should be declared as regular variables or static class properties, using all uppercase letters.

Node.js / V8 supports mozilla's const extension, but unfortunately that cannot be applied to class members, nor is it part of any ECMA standard.

JavaScript

Right:

var SECOND = 1 * 1000;

function File() {
}
File.FULL_PERMISSIONS = 0777;

Wrong:

const SECOND = 1 * 1000;

function File() {
}
File.fullPermissions = 0777;