how to display data type js code example Example 1: type javascirpt console.log(typeof 42); Example 2: check data type in js var x = "Hello World"; typeof x; // "string"