How can I get/check the contents of a cart via javascript (cookie)?
The cookie that Craft Commerce uses for cart/session management is set using Craft's craft()-&gt;userSession-&gt;saveCookie, which hard-codes cookie's httpOnly flag, meaning it can't be accessed by JavaScript.

If you want to pull of what you're trying to do, you'll need to use something like the LJ Cookies or Cookies plugin to add and ready your own cookie according to your business logic.