"in" statement in Javascript/jQuery

javascript, jquery

Solution

It does have an `in` operator but is restricted to object keys only:

var object = {
    a: "foo",
    b: "bar"
};

// print ab
for (var key in object) {
    print(key);
}

And you may also use it for checks like this one:

if ("a" in object) {
    print("Object has a property named a");
}

For string checking though you need to use the indexOf() method:

if ("abc".indexOf("a") > -1) {
    print("Exists");
}

Problem

Does Javascript or jQuery have sometime like the "in" statement in Python? "a" in "dea" -> True Googling for the word in is hopeless :(

Original source