Variablat dhe Vlerat e Parazgjedhura në JavaScript

Gjithashtu mund të ndryshoni emrat e variablave sipas dëshirës duke caktuar vlera të parazgjedhura:

javascriptlet obj = {
  month: 12,
  day:   31,
};

let {year:y = 2025, month, day} = obj;

console.log(y);     // shfaq 2025
console.log(month); // shfaq 1
console.log(day);   // shfaq 31
Задание 1

Në kodin vijues pjesët e objektit shkruhen në variablat përkatëse:

javascriptlet options = {
  width:  400,
  height: 500,
};

let c;
if (options.c !== undefined) {
  c = options.color;
} else {
  c = 'black';
}

let w = options.width;
let h = options.height;

Rishkruajeni këtë kod përmes destabilizimit sipas teorisë së mësuar.