Table of contents
- 1. Comments in JS
- what is a comment in JavaScript and why we need?
- how to write a comment for single line?
- how to write comment for multiple lines or JS block?
- 2. Data Types
- i. what are the data types?
- Note:
- ii. String Data Type
- iii. Boolean datatype
- Image
- Conclusion
- References Sololearn
- Author: Dheeraj.y
- Connect with me:
Today #day23 of #100daysofcode, I have completed 3 lessons and a practice program in JS, thus making the First module 1 complete in JS course. @Sololearn
1. Comments in JS
what is a comment in JavaScript and why we need?
- A comment is a non-executable JavaScript instruction.
- Comments help you are code more readable.
how to write a comment for single line?
- Add Two forward slash
//
to your code line.
how to write comment for multiple lines or JS block?
- Add
/*
at beginning of line and add*/
at end of the line.
2. Data Types
i. what are the data types?
- data types of different types of values a program language can take input.
- JavaScript can handle many different types of data like numbers, strings, arrays.
Note:
- In JavaScript you can redeclare the same variable name with another data type value.
Var
isn't correct keyword.var
is correct keyword in JS. Js is case sensitive.
ii. String Data Type
- String data type in JavaScript stores string data value.
- you can store manipulate text in string data type.
- If you start a string with single quote then you need to end with single quote.
-
\
is an escape character. Example:
var name1 = "My name is Dheeraj"
document.write(name1) \\My name is Dheeraj
var name1="<br>I am 'batman'"
document.write(name1) \\I am 'batman'
var name1="<br>I am \'Ironman\'"
document.write(name1) \\I am 'Ironman'
Code: output
iii. Boolean datatype
- boolean data type returns true or false.
- the boolean value of zero null undefined empty string is false.
- the boolean value of real value is true.
Image
Conclusion
- Comments in javascript.
- Data types in JavaScript.
- String data types
- Boolean data types
- Program problems
- Quiz