javascript-in_and_hasOwnProperty

Javascript ‘in’ and ‘object.hasOwnProperty’

1
var book = {
2
    title: "High Performance JavaScript",
3
    publisher: "Yahoo! Press" 
4
};
5
6
alert(book.hasOwnProperty("title"));  //true
7
alert(book.hasOwnProperty("toString"));  //false
8
alert("title" in book); //true 
9
alert("toString" in book); //true
Share