Home

JavaScript data types

Open the developer console to see the result


const nr = 17;
const str = 'John Doe';
const bool = true;
const arr = ['red', 'green', 'blue'];
const obj = { firstName: 'John', lastName: 'Doe' };
const noValue = null;
const undef = undefined;

console.log('typeof nr:', typeof nr); // typeof nr: number
console.log('typeof str:', typeof str); // typeof str: string
console.log('typeof bool:', typeof bool); // typeof bool: boolean
console.log('typeof arr:', typeof arr); // typeof arr: object
console.log('typeof obj:', typeof obj); // typeof obj: object
console.log('typeof noValue:', typeof noValue); // typeof noValue: object
console.log('typeof undef:', typeof undef); // typeof undef: undefined