Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

data types in javascript

// Data types in JavaScript
// In JavaScript, there are seven fundamental data types:
// first 6 is primitive data types (string, number, boolean, null, undefined, Symbol) and last one is complex data types (Object).

// Number: Any number, including numbers with decimals: 4, 8, 1516, 23.42.
let num = 23;
let num1 = 1.4;

// String: Any grouping of characters on your keyboard (letters, numbers, spaces, symbols, etc.) surrounded by single quotes: ' ... ' or double quotes " ... ", though we prefer single quotes. Some people like to think of string as a fancy word for text.
let name = 'chetan';
let name1 = 'ujesh';

// Boolean: This data type only has two possible values— either true or false (without quotes). It’s helpful to think of booleans as on and off switches or as the answers to a “yes” or “no” question.
let value = true;
let value1 = false;

// Null: This data type represents the intentional absence of a value, and is represented by the keyword null (without quotes).
let ans = null;

// Undefined: This data type is denoted by the keyword undefined (without quotes). It also represents the absence of a value though it has a different use than null. undefined means that a given value does not exist.
let que;
let coding;

// Symbol: A Symbol is a unique and immutable primitive value and may be used as the key of an Object property.
let sym = Symbol();
let sym1 = Symbol('foo');

// Object: An object contains properties, defined as a key-value pair. A property key (name) is always a string, but the value can be any data type, like strings, numbers, booleans, or complex data types like arrays, function and other objects.

// Array
let myArr = ['My','Name','is','Chetan'];
// Object
let person = {'firsName':'Chetan', lastName:'Nada' 'age':32};
// Function
let myFunction = function(){
    return "Thanks for Reading Data types in JavaScript";
}
Source by www.interviewbit.com #
 
PREVIOUS NEXT
Tagged: #data #types #javascript
ADD COMMENT
Topic
Name
7+3 =