cancel
Showing results for 
Search instead for 
Did you mean: 

How do typeof and instanceof work?

Palermo
New Contributor II

There are two special operators related to data types in SnapLogic. These operators are typeof and instanceof. The names look like the operators in JavaScript but they don't work like in Javascript.

 

const a = new String("Hello world");
const b = String("Hello world");
const c = "Hello world";
console.log(a instanceof String); // true
console.log(b instanceof String); // false
console.log(c instanceof String); // false
console.log(typeof a); // object
console.log(typeof b); // string
console.log(typeof c); // string

 

in SnapLogic:

 

"Hello world" instanceof String /* true */
typeof "Hello world" /* string */

 

SnapLogic expression language doesn't support classes then what are the instances mentioned in the SnapLogic documentation for the special operator instanceof? 

As I know SnapLogic was implemented with Java. Using the Type Inspector I found the following data types:

  • java.lang.String
  • java.math.BigInteger
  • java.math.BigDecimal
  • org.joda.time.LocalDate
  • org.joda.time.LocalTime
  • org.joda.time.LocalDateTime
  • org.joda.time.DateTime
  • java.util.ArrayList
  • java.util.LinkedHashMap
  • java.lang.Boolean
  • java.lang.Object
  • null

Maybe instanceof derives the names from the Java data types?

I also noticed another data types in the snap Mapper for schema. What the difference between the data types for typeof and Mapper?

  • string
  • integer
  • number
  • date
  • time
  • local-date-time
  • date-time
  • array
  • object
  • boolean
  • any

All the things confuse me.

0 REPLIES 0