“JavaScript Const” Kod odpowiedzi

Stałe JavaScript

const x = 5;
x = 10;  // Error! constant cannot be changed.
console.log(x)
SAMER SAEID

JS Zdefiniuj stałą według identyfikatora elementu

const elem = document.getElementById('elementID');
Ugly Unicorn

JavaScript Const

const PI = 3.141592653589793;
PI = 3.14;      // This will give an error
PI = PI + 10;   // This will also give an error
naly moslih

const {coś} JavaScript

const obj = {
  name: "Fred",
  age: 42,
  id: 1
}

//simple destructuring
const { name } = obj;
console.log("name", name);

//assigning multiple variables at one time
const { age, id } = obj;
console.log("age", age);
console.log("id", id);

//using different names for the properties
const { name: personName } = obj;
console.log("personName", personName);
 Run code snippet
Khoa Vo

Odpowiedzi podobne do “JavaScript Const”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu