Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /*
  2. * CONTROL FLOW:
  3. *
  4. * 0. Control flow is the idea of making decisions in code through the careful
  5. * use of booleans. We can ask our code a question and how a course of action
  6. * laidout for the 2-3 possible answers given such a situation.
  7. * My tools of choice for control flow are if, elseif, else statements.
  8. * In each statement it boils down to which statement will come true? So that
  9. * the code linked to the statement may run. Again I'll be sharing examples
  10. * of some of my work I've completed related to the study.
  11. */
  12.  
  13. var thisGuy = {
  14. eyes: "brown",
  15. age: 21,
  16. name: "Taijon",
  17. };
  18.  
  19. function isObject(value) {
  20. if (null === value) return false;
  21. else if (Array.isArray(value)) return false;
  22. else if (value instanceof Date) return false;
  23. else if (typeof value === "object") return true;
  24. else return false;
  25. }
  26. console.log(isObject([])); //prints false. [] an array does not pass the test
  27. //being an object.
  28. console.log(isObject(thisGuy));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement