在下面的代碼中我想打印小於34的「years_of_experience」和等於「texas」的出生地的值。但我沒有收到怎麼寫語句正確如何檢查一個對象的屬性等於某個值?
var employees = [
{
name1:'jacob',
age2 : 23,
date_of_join : 23/03/2013,
years_of_experience : 12,
birth_place: "virginia"
},
{
name2:'sheldon',
age2 : 34,
date_of_join :2/03/2013,
years_of_experience : 15,
birth_place: "lisbon"
},
{
name3:'johnny',
age3 : 25,
date_of_join :29/03/2013,
years_of_experience : 13,
birth_place: "texas"
}];
employees.forEach(function(a) {
console.log(a);
});
for(var i = 0;i <= employees.length;i++)
{
if(employees[i]!= -1)
{
console.log("gotcha");
if(employees.hasOwnProperty === years_of_experience) < 34 || (employees.hasOwnProperty(birth_place) === "teaxs")
{
//here i want to print the values of
// "years_of_experience" which is less than 34 and birthplace which is equal to
// "texas".But i'm not getting how to write the statement for that become m new to
// javascript and even m not sure i've written the conditional statement right,
// please correct it and help me..
}
}
}
[任何具體問題?](http://stackoverflow.com/faq) – Lion 2013-04-20 14:18:30
如果(僱員[I] [ 「years_of_experience」] <34 ||(僱員[i] [「birth_place」] ===「texas」) – mplungjan 2013-04-20 14:19:20
嘿thanx獅子使條件聲明寫,但我將如何打印值,我將從條件後得到真實的 – user1976940 2013-04-20 14:21:44