method1('id','name')
This is the method I called.
Array.prototype.method1 = function (property) {
console.log(property) //Expect ['id','name']
)
I want to get result like ['id','name']
const property = property.split(",");
console.log(property) //This shows only ['id']
Can anyone help me to do this?
CodePudding user response:
Here you can try two ways :
function check() {
console.log([...arguments])
}
check(1,2,"apple")
CodePudding user response:
Try the following. Will output what you're expecting, but not sure that JS experts would write code like this.
var s = "id,name";
var a = s.split(",");
Array.prototype.method1 = function(property) {
console.log(property); //Expect ['id','name']
}
a.method1(a); //this will display your expected