10 Things a JS Developer Know


const example1 = “100”;parseFloat(example1) // to convert string to number


‘Jhon’.length // to find how many characters in this string
‘hello’.charAt(3) // is a thing that returns the characters of strings to that location.
‘hello, world’.replace(‘world’, ‘earth’)// to replace the old value to new value.
‘sahil’.toUpperCase()// to convert all string to upper case.
‘SAHIL’.toLowerCase()// to convert all string to lower case.
const stringObj = new String(‘foo’);console.log(stringObj);
// output
const toStaring = stringObj.toString()// convert object to stringconsole.log(toStaring);
// output


const plants = [‘broccoli’, ‘cauliflower’, ‘cabbage’, ‘kale’, ‘tomato’];const pop = plants.pop()// to remove last string of arrayconsole.log(pop)console.log(plants)// outputplants.pop();console.log(plants);// output
const animals = [‘pigs’, ‘goats’, ‘sheep’];const count = animals.push(‘cows’);// to add a string after last string of arrayconsole.log(count)// output: 4console.log(animals)// outputanimals.push(‘chickens’, ‘cats’, ‘dogs’);// to add a string after last string of arrayconsole.log(animals)// output
const animals = [‘ant’, ‘bison’, ‘camel’, ‘duck’, ‘elephant’];const slice =animals.slice(2)// get the first two stringconsole.log(slice);console.log(animals)// expected outputanimals.push(‘chickens’, ‘cats’, ‘dogs’);console.log(animals)// expected output