// CLASS TOPICS : FEW METHOD OF DATA TYPES
// TO LOWER CASE
// myVal = "HELLO".toLowerCase()
// console.log(myVal);
// it will convert whole string to lowercase like "hello"
// TO UPPER CASE
// myVal = "hello"
// myVal2 = myVal.toUpperCase()
// console.log(myVal2)
// it will convert whole string to uppercase like "HELLO"
// REPLACE
// myVal = "hello".replace("ll","b")
// console.log(myVal);
// it will replace some part of string to something else
// here it will replace ll to b
// SPLIT
// myVal = "hello".split("e")
// console.log(myVal);
// it will split the string in diffrent part acc to the charac you have passed
// SUBSTRING
// myVal = "hello".substr(0,2)
// console.log(myVal);
// it will return substring first value you are passing to substr is
// a index from where you want to start
// and second value that you passing is length of string that you need
// TRIM
// myVal = " hello ".trim()
// console.log(myVal);
// it will remove all spaces before and after a string or b/w a string
// SLICE
// myVal = "hello world".slice(0,6)
// console.log(myVal)
// it will return part of string
// first value : a index from where you want to start
// and second value : a index from where you want to end
// CLASS TOPICS : STRING DATA TYPE // "H" , "E" , "L", "O" // string is a combination of few characters // we can re-assign variables as done below // myValue = 'hello' // console.log(myValue, 'called') // myValue = 1 // console.log(myValue, 'called 2') // myValue = [1,2,3] // console.log(myValue,'called 3') // we can access charac from string same as we can do with array's // myValue = "hello" // myCharac = myValue[2] // console.log(myCharac); // we can create space b/w charac too // myValue = "hello " + "world" // console.log(myValue) // behind the scenes space is also being stored like this: ["h","e","l","l","o",""] // we can use \n to print data in next line // myValue = "hello my name is: \n shagun" // console.log(myValue); // we can also use \t to create space between words in the same line
Comments
Post a Comment