Skip to content
Advertisement

Tag: comparison

How to compare two Moment.js Objects

I have an Array with Moment.js objects in a variable: And a function to determinate if a value is in this array: But even if i pass a moment object, as checkFeriado(moment(“2016-01-01”)); i’m getting false. Whats wrong with my code? Is there a best way to do this? Entire project have jQuery and Moment.js Answer Javascript objects cannot be compared

Javascript – deepEqual Comparison

Question (From Eloquent Javascript 2nd Edition, Chapter 4, Exercise 4): Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with the same properties whose values are also equal when compared with a recursive call to deepEqual. Test Cases: My code: I think I have the general idea down;

Comparing negative numbers in javascript

I’m sure this is a simple problem, but I’m comparing negative numbers in javascript i.e.: This script will always take action 2, even though num1 is less than num2. Whats going on here? Answer How does if (parseFloat(num1) < parseFloat(num2)) work? Maybe your numbers are turning into strings somewhere.

Advertisement