Created
August 30, 2020 13:29
-
-
Save rahulmalhotra/7a3444ecfae2d6f75f5b146a009d68a2 to your computer and use it in GitHub Desktop.
This code snippet is being used in Everything about constants in JavaScript Tutorial on SFDC Stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// * Constants in Javascript | |
// * Initialize a constant while defining it | |
const MONUMENT = 'Taj Mahal'; | |
console.log(MONUMENT); | |
// * Constant can only be initialized once, at the time of definition | |
// MONUMENT = 'Lal Quila'; | |
// console.log(MONUMENT); | |
// * We can assign an object to a constant | |
const USER = { | |
firstName : 'Rahul', | |
lastName : 'Malhotra' | |
}; | |
console.log(USER); | |
// USER = { | |
// firstName : 'Richard', | |
// lastName : 'Hendricks' | |
// }; | |
/* | |
* If a constant is an object, then I cannot update that whole constant | |
* but we can update the properties of that constant | |
*/ | |
USER.firstName = 'Richard'; | |
USER.lastName = 'Hendricks'; | |
console.log(USER); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment