Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

var or const in javascript

// var declares a variable, meaning its value will vary. 
// const declares a constant, meaning its value will remain 
// consistant and not change. 
// If your variable changes throughout the program or website, 
// declare it using a var statement. 
// Otherwise, if its value does not change, declare it using 
// a const statement. 

const myConst='A const does not change.';

var myVar='A var does change.';

var myVar=2;
Comment

const { something} 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
Comment

javascript const

const b = 1; // this variable unique and can't change it. 
Comment

JavaScript Const

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

what is const in javascript

const age; // errror as const cannot be kept un-initialized;
const age = 20 ; 
const age = 21 , // error as once declared const variable cann't be
// re-declared in same scope or different scope. 
Comment

JavaScript Constants

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

const in javascript

const value = 10;
const constant = value;
Comment

PREVIOUS NEXT
Code Example
Javascript :: print console.log 
Javascript :: remove row from array javascript 
Javascript :: chrome-aws-lambda 
Javascript :: get item in array from index 
Javascript :: particle js 
Javascript :: ant design form validation in the modal 
Javascript :: jqvmap 
Javascript :: js pass variable from iframe to parent window 
Javascript :: for ... of ... 
Javascript :: update data in sequelize 
Javascript :: how to pass props in react 
Javascript :: connect redux 
Javascript :: js filter array 
Javascript :: javascript this keyword 
Javascript :: remove element json javascript 
Javascript :: javaScript delete() Method 
Javascript :: javasript object 
Javascript :: react-dropzone-uploader 
Javascript :: how we can set react select required 
Javascript :: Material-ui account icon 
Javascript :: how to make and add to an array in javascript 
Javascript :: get js 
Javascript :: binding style vuejs 
Javascript :: search in javascript 
Javascript :: jquery from js 
Javascript :: fs.readfilesync withFileTypes true 
Javascript :: Sort Date string in javascript 
Javascript :: .default in javascript 
Javascript :: jquery val style 
Javascript :: formatt json to create node and child node react 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =