Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

primitive and non primitive data types in javascript

//primitive = {STRING, NUMBER, BOOLEAN, SYMBBOL, UNDEFIEND, NULL}
//non-primitive = {ARRAY, OBJECT, FUNCTION}

//primitive is always copied by VALUE
var a = 1;
var b = a;
    //console.log(a , b) =  1 , 1
a = 3;
console.log(a) //3
console.log(b) // still 1 and not 3   (always copied by value only)


//non-primitive is always copied by REFERENCE
var x = {name : "Jscript"};
var y = x;
  //console.log(x , y)     TWICE =  Object { name: "Jscript" }
x.name = "Js";
console.log(x) //Js
console.log(y) //Js  {copied by reference} like pointers in C lang
Comment

primitive data types in javascript

/*
boolean.
bigint.
null.
number.
string.
symbol.
undefined.
*/
best way to remember is BBNNSSU
Comment

javascript primitive data types

Primitive Data Types
Primitive data types in JavaScript include:

Numbers - Integers, floats
Strings - Any data under single quote, double quote or backtick quote
Booleans - true or false value
Null - empty value or no value
Undefined - a declared variable without a value
Symbol - A unique value that can be generated by Symbol constructor
Comment

javascript non primitive data types

Non-primitive data types in JavaScript includes:

Objects
Arrays
Comment

JavaScript, numbers are primitive data types

const a = 3;
const b = 3.13;
Comment

WHAT IS JAVASCRIPT PRIMITIVE AND NON PRIMITIVE DATA TYPE ?

Quas : WHAT IS JAVASCRIPT PRIMITIVE AND NON PRIMITIVE DATA TYPE ?
Ans  : 

primitive =>

 STRING => var myName = 'iqbal';

 NUMBER => var myAge = 25;

 BOOLEAN => var iAmStudent = true;

 symbol => +, -, *, /, %  +=, -=, ++, --, <, >, =, ==, ===, !==, !=, <=, >=  
 
 undefined => A variable that has not been assigned a value of your code
 
 null => Null means having no value
 
 
non-primitive =>
 ARRAY =>
 var friendsName = ['habib', 'iqbal', 'shorif', 'asraful', 'rasel', 'arif', 'deader' ];
 

 OBJECT =>
 var mobile = {
     brand : 'iPhone',
     price : 79000,
     storage : '64gb',
     camera : '50MP'
  }


 FUNCTION =>
 function isEven(number){
    const remainder = number % 2;
    if(remainder === 0){
        return true;
    }
    else{ 
        return false;
    }
}

const evEnNumber = 180;
const evenNumber2 = 185;
const toTalEven = isEven(evEnNumber);
const totalEven2 = isEven(evenNumber2);
console.log(toTalEven);
console.log(totalEven2); 
Comment

PREVIOUS NEXT
Code Example
Javascript :: Add New Properties to a JavaScript Object 
Javascript :: console.log object functions js 
Javascript :: get selected option from select javascript 
Javascript :: image file upload in angular 
Javascript :: Get async: false 
Javascript :: CodePen Home Load iframe on click 
Javascript :: javascript remove everything after . 
Javascript :: javascript array erstellen 
Javascript :: dart how to convert json to x-www-form-urlencoded 
Javascript :: convert string to integer javascript 
Javascript :: Setting up an Express project 
Javascript :: splice javascript 
Javascript :: how to check with jquery if bootstrap modal is hidden or shown 
Javascript :: react axios POST using async await method with super constructor parent class 
Javascript :: javascript upload file button 
Javascript :: jest mock call 
Javascript :: angular convert boolean to yes no 
Javascript :: js double click to edit 
Javascript :: javascript find area of triangle 
Javascript :: localstorage.setitem 
Javascript :: window.focus and window.blur jquery 
Javascript :: Monitor in production node js 
Javascript :: js not not 
Javascript :: Add Multilanguage Support to React App 
Javascript :: how to hide api key in react 
Javascript :: how to get the lower triangular matrix out of a matrix matlab 
Javascript :: rounding to two decimal places 
Javascript :: sorting algorithms in node.js 
Javascript :: how to push in object in javascript 
Javascript :: how to use two text fields in one single row react js 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =