How to use an array of values in javacript?
- by admin
- 0
As usual arrays we can add values into an array variable using commas as separator along with other properties.
function myobjs(){
this.name= “john”; //Property
this.age= “20”; //Property
this.nickname=[“a”,”b”,”c”]; //Array
this.allname=function(){ // array values using in function
this.nickname.forEach(function(eachname){
console.log(eachname);
});
}
}
var insta_myobj=new myobjs();
insta_myobj.allname();
As usual arrays we can add values into an array variable using commas as separator along with other properties. function myobjs(){ this.name= “john”; //Property this.age= “20”; //Property this.nickname=[“a”,”b”,”c”]; //Array this.allname=function(){ // array values using in function this.nickname.forEach(function(eachname){ console.log(eachname); }); } } var insta_myobj=new myobjs(); insta_myobj.allname();
As usual arrays we can add values into an array variable using commas as separator along with other properties. function myobjs(){ this.name= “john”; //Property this.age= “20”; //Property this.nickname=[“a”,”b”,”c”]; //Array this.allname=function(){ // array values using in function this.nickname.forEach(function(eachname){ console.log(eachname); }); } } var insta_myobj=new myobjs(); insta_myobj.allname();