-1

For example, API response is: "Test": { "Test1": 390, "Test2": "391" }

I just want check that the Test1 returning integer value and Test2 is returning string value without verifying the actual value (ex: 390) returned by the field.

Tester77
  • 309
  • 1
  • 4
  • 10

2 Answers2

1

isNaN returns true if the supplied argument isNotaNumber. (i.e. you want false from isNaN)

var obj = { val: 12345 };
console.log(!isNaN(obj.val)); // true. its integer
mehulmpt
  • 15,861
  • 12
  • 48
  • 88
0

you can use typeof(), ie:

var montexte="montexte"
var monchiffre=50

console.log('texte ? ' + typeof(montexte)) // gives string
console.log('chiffre ? ' + typeof(monchiffre)) // gives number

hope this helps

A.Joly
  • 2,317
  • 2
  • 20
  • 25