const data = {
name: "javascript",
name: "React"
}
const result = data.name.at(-2);
console.log(result);
Output:
c
- In JavaScript Objects if we have duplicate property names, only the last definition will be retained. So in this case
data.namewill be"React". - .at(-2) will give the second character from the last which is ‘c’ in this case.