openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.96k stars 530 forks source link

IsObject(null) returns null, not false #179

Open elenaparaschiv opened 7 years ago

elenaparaschiv commented 7 years ago

Problem: The function isObject should return true or false, depending if the supplied parameter is a true object, but if we call it with null it will return null

isObject(null)
//returns null

Solution: If we wrap the value inside !! we avoid this edge case, ensuring false will be returned if the parameter is null

isObject(null);
// returns false
asutosh97 commented 7 years ago

Rightly pointed out. I was also going through the codebase and figured it out now. Thought of making a PR, but saw yours. Good job 👍