A. KULLANIM

1. Tanımlama ifadeleri

Blok tabanlı ve kullanım amacına uygun tanımlama yolları kullanılmalıdır.

Doğru Örnek:

const pi = 3.14;
const limit = 5;
let counter = 0;

for (let i = 0; i < number; i++) {
  counter++;
}

Yanlış Örnek:

// BAD: pi is a constant, use const instead
let pi = 3.14;
// BAD: var is not block-scoped, use const instead
var limit = 5;
let counter = 0;

// BAD: var is not block-scoped, use let instead
for (var i = 0; i < number; i++) {
  counter++;
}

2. Nesne tanımlama

Nesneler tanımlanırken tutarlı bir biçimlendirilme kullanılmalıdır.

Doğru Örnek:

const recordInfoShort = {
  firstName,
  lastName,
};

const recordInfoLong = {
  firstName:      firstName,
  lastName:       lastName,
  age:            36,
  [hometownProp]: "Izmir",
};

Yanlış Örnek:

// BAD: inconsistent shorthand usage
const recordInfoShort = {
  firstName,
  lastName: lastName,
};

// BAD: inconsistent quote usage
const recordInfoLong = {
  firstName,
  lastName:  lastName,
  "age":     36,
};

// BAD: could be merged with definition
recordInfoLong.hometownProp = "Izmir";