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

const in javascript

const value = 10;
const constant = value;
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to find keycode in javascript 
Javascript :: datatable buttons bootstrap 4 
Javascript :: bash json creator 
Javascript :: ng-lazyload-image 
Javascript :: Material-ui cold icon 
Javascript :: react router link electron not working 
Javascript :: Fake Binary 
Javascript :: react linking to documents 
Javascript :: javascript decrement 
Javascript :: accept json data in express 
Javascript :: string to char code array javascript 
Javascript :: angular convert boolean to yes no 
Javascript :: adding data attributes to react-select 
Javascript :: adding hbs partials in express.js 
Javascript :: react-intersection-observer 
Javascript :: find consecutive numbers in an array javascript 
Javascript :: Create A Promise And Then Return It 
Javascript :: how to copy all elements in an array except for the first one in javascript 
Javascript :: react native full screen view video player 
Javascript :: react native camscanner application mobile code 
Javascript :: how to keep a child window always on top in electron js 
Javascript :: res.write in node js 
Javascript :: rc-notification react 
Javascript :: react write into json file 
Javascript :: sendgrid mail unique args 
Javascript :: vuejs enter phone with country flag 
Javascript :: react native ios assessibility font size 
Javascript :: how to convert json to javascript object 
Javascript :: array of objects in javascript short 
Javascript :: array.splice 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =