Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript add field to array

  //you can add custom properties to the JS arrays
  //length won't change
  
  const arr = [ 1, 2, 3, 4 ];
  arr.greeting = 'Hello, world!';

  console.log(arr.length); // 4
  console.log(arr.greeting); // Hello, world!
Source by learn.coderslang.com #
 
PREVIOUS NEXT
Tagged: #javascript #add #field #array
ADD COMMENT
Topic
Name
4+3 =