Trying to master JavaScript, in your web development journey? 💪🏻
Get started with the fundamentals: Variables and Data Types (đź§µ):
Get started with the fundamentals: Variables and Data Types (đź§µ):
(4/n)
➡️ In code line 1:
const fullName = "Jason Bourne"
Since name isn't going to change, we keep it constant (“const").
“fullName” is the name of the variable that stores the value “Jason Bourne”. A variable is anything holding some value.
➡️ In code line 1:
const fullName = "Jason Bourne"
Since name isn't going to change, we keep it constant (“const").
“fullName” is the name of the variable that stores the value “Jason Bourne”. A variable is anything holding some value.
(5/n)
“=”, the assignment operator, assigns (read as, sets) the value of “fullName” to “Jason Bourne”.
“Jason Bourne” is the actual value you wanted to store. The double quotes around it tell Javascript, that what you are storing is a text value or a String value.
“=”, the assignment operator, assigns (read as, sets) the value of “fullName” to “Jason Bourne”.
“Jason Bourne” is the actual value you wanted to store. The double quotes around it tell Javascript, that what you are storing is a text value or a String value.
(6/n)
➡️ In code line 3:
let age = 22
“const” is used to define something that is meant to remain the same like, “fullName”, and “age” is something that will change. For age, we are using “let” which helps you define variables that can change their values.
➡️ In code line 3:
let age = 22
“const” is used to define something that is meant to remain the same like, “fullName”, and “age” is something that will change. For age, we are using “let” which helps you define variables that can change their values.
(7/n)
➡️ In code line 5, you have:
console.log('fullName: ${fullName}|birthPlace: ${birthPlace}|age: ${age}')
Browser Logs:
fullName: Jason Bourne | birthPlace: USA | age: 22
“console.log()” basically prints anything you put inside the brackets on the Browser Logs tab.
➡️ In code line 5, you have:
console.log('fullName: ${fullName}|birthPlace: ${birthPlace}|age: ${age}')
Browser Logs:
fullName: Jason Bourne | birthPlace: USA | age: 22
“console.log()” basically prints anything you put inside the brackets on the Browser Logs tab.
(8/n)
The browser log tabs display the 3 variables you had stored.
${fullName} → “Jason Bourne”
${birthPlace} → “USA”
${age} → 22
Rest of the output is just text
The browser log tabs display the 3 variables you had stored.
${fullName} → “Jason Bourne”
${birthPlace} → “USA”
${age} → 22
Rest of the output is just text
(9/n)
The things inside the bracket are also enclosed between ` `. These are called backticks.
If you use backticks, anything inside ${...} will be replaced by the variable value you put in the curly braces.
This format is called string template literals.
The things inside the bracket are also enclosed between ` `. These are called backticks.
If you use backticks, anything inside ${...} will be replaced by the variable value you put in the curly braces.
This format is called string template literals.
đź’ˇFurther Details on Variable & Data Types (10/n):
Difference between “let” & “const”
You might be wondering what if Jason has a middle name Harrison that he wants to add to the variable?
Difference between “let” & “const”
You might be wondering what if Jason has a middle name Harrison that he wants to add to the variable?
(15/n)
➡️ In line 2:
On printing age to the console, you get the value as “undefined” because, when a variable is declared, but not given a value, JavaScript assigns it a default value of “undefined”. It simply signifies that the programmer is yet to provide a value.
➡️ In line 2:
On printing age to the console, you get the value as “undefined” because, when a variable is declared, but not given a value, JavaScript assigns it a default value of “undefined”. It simply signifies that the programmer is yet to provide a value.
(19/n)
Awesome! ✨ You learned about “let”, and "const", along with data types like Number, String, null and undefined! To read the full blog by @rishabhs_twt head over to: codedamn.com
Awesome! ✨ You learned about “let”, and "const", along with data types like Number, String, null and undefined! To read the full blog by @rishabhs_twt head over to: codedamn.com
(n/n)
In the next one, you will learn more about the Object Data Type and a few JS Operators. Until then stay tuned & share this thread. Don't forget to keep practicing on codedamn playgrounds! đź’»
In the next one, you will learn more about the Object Data Type and a few JS Operators. Until then stay tuned & share this thread. Don't forget to keep practicing on codedamn playgrounds! đź’»
Loading suggestions...