Hi I'm new in JavaScript and i find a basic problem:
When I use that piece of code in Python:
'a' in 'aaa'
I get True
When I do the same in JavaScript I get Error:
TypeError: Cannot use 'in' operator to search for 'a' in aaa
How to get similar result as in Python?
Answer
I think one way is to use String.indexOf()
'aaa' .indexOf('a') > -1
In javascript the in operator is used to check whether an object has a property
No comments:
Post a Comment