[removed] using typeof to check if string

前端 未结 6 1915
萌比男神i
萌比男神i 2021-02-14 15:32

I\'m working on a codecademy.com exercise where we use for-in statements to loop through an object and print hello in different languages by checking to see if the values of the

6条回答
  •  遥遥无期
    2021-02-14 16:03

    "string" is not the same as String. I've found one way to test typeof for string.

    if (typeof something === typeof "test") ...
    

    You can of course use "string" to compare to, but any actual String will do.

提交回复
热议问题