JAVASCRIPT #2 (STRINGS)
// STRING CONTINUE......
let age = 22;
let firstName = "harshit";
console.log(typeof age);
// number to string convert...
age = age + "";
console.log(typeof age );
// strings to number convert...
let myStr = "34";
myStr = +"34";
console.log(typeof myStr);
//another method....
//to convert number to string...
let aGe = 18;
aGe = String(aGe);
console.log(typeof aGe);
//to convert string to number...
aGe = Number(aGe);
console.log(typeof aGe);
// string concatenation...
let string1 = "kangkana";
let string2 = "kalita";
let fullName = string1 + " " + string2;
console.log(fullName);
let str1 = "18";
let str2 = "20";
let newStr = +"18" + +"20";
console.log(newStr);
// template string
let old = 22;
let firstname = "kangkana";
// "my name is kangkana and my age is 20"
let aboutMe = "my name is " + firstname + "and my age is " + old;
console.log(aboutMe);
aboutMe = `my name is ${firstname} and my age is ${old}`;
console.log(aboutMe);
// undefined
//null
let lastName;
console.log(typeof lastName);
lastName = "kalita";
console.log(typeof lastName, lastName);
let myVariable = null;
console.log(myVariable);
myVariable = "kangkana";
console.log(myVariable, typeof myVariable);
console.log(typeof null);
// object is bug, error
//BigInt
let myNumber = 123;
console.log(Number.MAX_SAFE_INTEGER);// js say about what limit i can set numbers.
//way to set BigInt
//BigInt can not operate with other type...
myNumber = BigInt(12);
let sameMyNumber = 123n;
console.log(myNumber + sameMyNumber);
Output:

Comments
Post a Comment