Data Types
Data Types
Number
All JavaScript numbers are stored as decimal
numbers (floating point).
Project_pulse
Project_pulse
1 let name;
2
3 console.log(name);
4
5 //output: null
6
String Methods
String are used to store textual form of data like word,
sentence. It follows zero based indexing.
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
1 let str="PROject_pulse";
2
3 let index=str.indexOf("p");
4
5 console.log(conv);
6
7 //Output: “8”
indexOf()
The indexOf() method finds the first occuurence of a
specified value in a string and returns its position. In
this example, it returs the position of string “p” in the
message, which is 8.
Project_pulse
1 let str="PROject_pulse";
2
3 console.log(str.indexOf(“p”));
4
5 //Output: “8”
6
7
lastIndexOf()
The lastIndexOf() method in JavaScript returns the
index of the last occurrence of a specified value in a
string or array. It searches from the end to the
beginning and returns -1 if the value is not found.
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse
Project_pulse