I\'ve experimented with JavaScript and noticed this strange thing:
var s = \"hello world!\";
s.x = 5;
console.log(s.x); //undefined
Every t
Skilldrick’s answer explains why it doesn’t work and therefore answers your question.
As a side note, it is possible to do this:
var s = {
toString: function() { return "hello world!"; }
};
s.x = 5;
console.log(s.x); // 5
console.log('result: ' + s); // "result: hello world!";
console.log(String(s)); // "hello world!";