0
Need explain[Solved]
Why last one print 421 instead of 43 https://code.sololearn.com/WbvApWnmnPr4/?ref=app
4 Respostas
+ 5
because window.name is used to store the window name... as a string ^^
so assigning it a number cast it to a string, and a string plus a number result to concatenating string and number casted to string ;)
+ 3
not a bug: name is a property of window, and store its value as a string...
+ 3
you could overide it by redefining the property explicitly:
Object.defineProperty(window,'name',{
value: null,
writable: true,
})
+ 1
visph ok, I guess I'm just too used to Node.js nowadays. Anyways, 42 is being assigned to `name`, then why is it being stored as string?