javascript - How to store number of object element of array in another array? -
There have been some object elements try to collect from one array to another, so you can say that I have objects I> P>
var array = [{name: 'fictitious'}, {name: 'joseph'}, {name: 'salim'}, {name: 'tony'}]; I want to store another array to the first two objects in the array do so
var SubArray = [[name: 'Fadi' } {Name: 'Joseph'}]; Thanks in advance for any help.
You can use the method for this:
var SubArray = Array.slice (0,2); Please note that for the variable that JS global item is reserved for, you have to use a different name. Your code should be, for example:
var MyArray = [{name: 'Fadi'}, {name: 'Joseph'}, {name: 'Salim'}, {name: Tony '}]; Var Sabarere = Myere Slices (0,2);
Comments
Post a Comment