ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What are the rules for determine the "truth" of any value not already of the Boolean type?

user-image
تم إضافة السؤال من قبل Saadia Idris , Employee , Jazz Company
تاريخ النشر: 2017/10/25
Ahmed Samir
من قبل Ahmed Samir , Web Developer , Raqy Company for Electronic Trading

  1. If the value is a number, it is false if exactly equal to zero and true otherwise.
  2. If the value is a string, it is false if the string is empty (has zero characters) or is the string "0", and is true otherwise.
  3. Values of type NULL are always false.
  4. If the value is an array, it is false if it contains no other values, and it is true otherwise. For an object, containing a value means having a member variable that has been assigned a value.
  5. Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
  6. Don't use double as Booleans. 

المزيد من الأسئلة المماثلة