can someone help me understand this piece of code?
let word = 'Nose';
word[0] = 'P';
console.log(word); // logs as "Nose"
console.log(word[0]); // logs as "N"
Shouldn't word[0] be 'P' and word should be 'Pose' right?
can someone help me understand this piece of code?
let word = 'Nose';
word[0] = 'P';
console.log(word); // logs as "Nose"
console.log(word[0]); // logs as "N"
Shouldn't word[0] be 'P' and word should be 'Pose' right?
Strings are immutable in javascript. They cannot be mutated but the variable can be reassigned a new value.
let str = "Hello";
str[0] = "M";
console.log(str);
str = "Mello";
console.log(str);