Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create immutable array in javascript

let x = [1, 2, 3]
let [...y] = x

// let's update the value of "x"
x.push(4)

console.log(x) // will return [1, 2, 3, 4]
console.log(y) // will return [1, 2, 3]
/* "y" haven't changed because it copied the value of "x" and made himself
a whole separated array, instead of just coping the reference of "x"
(reference copy case:- let y = x) */
/* NOTE: get some youtube classes about javascript reference type and primitive
data types, if you're not clear enough about what i mean by "reference" */
Comment

PREVIOUS NEXT
Code Example
Javascript :: spread operator shorthand javascript 
Javascript :: Exponent Power Shorthand in javascript 
Javascript :: javascript findindex para objeto json 
Javascript :: ingore render on refresh page 
Javascript :: reactjs ES6 class event listeners in jsx 
Javascript :: how to generate an array of random numbers in javascript 
Javascript :: Tableau JS api getdata 
Javascript :: simple promise 
Javascript :: compile regex script help online 
Javascript :: the key import is reserved 
Javascript :: take money from user and give change as output using javascript 
Javascript :: jasmine configrations 
Javascript :: downlaod file from website raect2 
Javascript :: javascript executes a script ________ 
Javascript :: simple method 
Javascript :: angular interpolation check if value is null 
Javascript :: navigating to another screen from the react native navigation header 
Javascript :: Public properties can be created via Static public fields 
Javascript :: koa wildcard route 
Javascript :: typeorm caching queries time limit globally 
Javascript :: How To Start Any Program In Background Using Vbscript 
Javascript :: online md5 decrypt 
Javascript :: observables loop in template angular 8 
Javascript :: Template literals in ES6 Syntax Concatenation 
Javascript :: format file using jq 
Javascript :: is enabled 
Javascript :: //testing 
Javascript :: loop through async javascript -IMP 
Javascript :: netlify not deploying react site 
Javascript :: 2495016599 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =