For a variable x=5, how do I know it is number five or the character ‘5’?
Btw, in JS, do characters follow the ASCII table? Then can I manipulate a character variable. For example, if variable x is character a, can I do x=x+1 to make it character b?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To see if x is the number 5, as opposed to the string “5”, you can use the identity operator:
Identity will not do any implicit conversions; it will return true only if both operands are equal without any conversions.
No.
x = x + 1will convert 1 to a string, perform string concatenation and return “a1”