Hello, what would the .length for numbers be, I tried assigning a variable to a number and then putting the variable in the console.log but it returns undefined, thanks fairly new to this.
Numbers are exact values that don’t have a length. Sure they have numeral characters, etc., but as objects they have no length. Further to this, numbers are not iterable.
Can somebody please explain this concept in simpler terms? Thank you very much
a = 42
Above we assign an integer value (a number) to the variable,
a. When we poll the type of
a we are actually polling the type of
a is not an object, but a reference to an object.
42 is identified by the interpreter as being a
number type so gives it a wrapper object of that type.
typeof 42 => 'number' typeof a => 'number'
a refers to an instance of a number type.
I think I understand it better now, thank you for your explanation sir.