I understand that javascript is dynamically-typed language so i can change the type of data assigned to a variable in javascript. Recently I started with javascript and found a strange behaviour when i was trying some commands in console window of google chrome browser. Please find the screen shot attached with the set of commands i ran through. In the 3rd command i am assigning number 10 to variable name which was created as string. But if i check the typeof name it still says string. I couldn't find a logical answer to this behaviour. But when i try the same sequence of instructions with other variable names it works as expected. Please can some explain this behaviour.
            Asked
            
        
        
            Active
            
        
            Viewed 40 times
        
    1 Answers
0
            
            
        All global variables in JavaScript in the Browser are properties of the window object. 
window.name must always be a string, so that the global variable name will always be converted to a string.
 
    
    
        NineBerry
        
- 26,306
- 3
- 62
- 93
