Recently, I encountered an issue with my JavaScript code.
var customer = {
name: "John Jack",
speak: function(){
return "my name is "+name;
},
address:{
street: '123 main st',
city: 'Pittsburgh',
state: 'PA'
}
}
document.write(customer.speak());
Expected output in my HTML:
my name is John Jack
However, the actual result was quite unexpected:
my name is Peaks mirroring in a lake below, Stubai Alps, Austria
I have been pondering over various theories as to why this strange output occurred. One suspicion is that it might be related to a Chrome extension I have installed called "Pixlr". But I fail to see how my JS code could be influenced by it. I even attempted modifying variable names and changing speak
to say
, yet the outcome remained unchanged. Can someone shed some light on what may be causing this anomaly?