I is a new brand for javascript, and is relatively new to programming in a complete form. I understand javascript mechanics, but I have been stumped in a situation like the following:
var dataTypes = {string1: "test", string2: "test", number1: 4,}; Console.log (type of data types.number1); Console.log (""); (For data type var x) {console.log (typef x); If ((typef x) === "string") {console.log (data type [x]); } Else {//}}
And when I run it, my console displays the following:
number string string test string 4 < / Code>
How confused I am that how dataTypes.number1
goes into a string with the number of data types, if any time elapses to take what I do To do this, and to explain, it will be amazing.
Your variable is different from the x
key data type
. So it's always a string.
You need to check the type types data type [x]
instead.
No comments:
Post a Comment