Quantcast
Channel: create a new array and push into it in one line - Javascript OOP - Stack Overflow
Viewing all articles
Browse latest Browse all 4

create a new array and push into it in one line - Javascript OOP

$
0
0

I've this code with a function, wherein a I'm trying to define an array then on the next line pushing to it:

function Spot(value) {  this.x = null;  this.y = null;  this.values = [];  this.values.push(value);}

I've tried this:

this.values = [].push(value);

and

this.values = (this.values || []).push(value);

But failed. Is there something wrong with the code.....


Viewing all articles
Browse latest Browse all 4

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>