arrays - Removing quotes from console log in JavaScript - Stack Overflow

I'm trying to remove the printed single quotations which occur while running the following code. I

I'm trying to remove the printed single quotations which occur while running the following code.

I've tried playing around with the replace(/['"]+/g, ''but I'm not getting this correctly.

var arr = ["Alpha", "Omega", "Delta"];
var symbol = "weee";
for(x=0; x<arr.length; x++){
    console.log(x,symbol,arr[x]);
}

This returns:

0 'weee' 'Alpha'

1 'weee' 'Omega'

2 'weee' 'Delta' 

I'm trying to remove the printed single quotations which occur while running the following code.

I've tried playing around with the replace(/['"]+/g, ''but I'm not getting this correctly.

var arr = ["Alpha", "Omega", "Delta"];
var symbol = "weee";
for(x=0; x<arr.length; x++){
    console.log(x,symbol,arr[x]);
}

This returns:

0 'weee' 'Alpha'

1 'weee' 'Omega'

2 'weee' 'Delta' 
Share Improve this question edited Mar 15, 2017 at 2:38 aircraft 27k29 gold badges101 silver badges174 bronze badges asked Mar 15, 2017 at 2:33 dpxdpx 1172 silver badges10 bronze badges 1
  • don't use chrome, it's the only console that does that (well, not quite ... my console uses double quotes in the output) ... anyway ... who cares how strings a shown in a debugging tool - it makes no difference to the code – Jaromanda X Commented Mar 15, 2017 at 2:49
Add a ment  | 

1 Answer 1

Reset to default 7

If the types of console.log parameters are different, string type will be marked by quotation marks, so you can make the parameters to a single string, just like:

 console.log(x + ' ' + symbol + ' ' +arr[x]);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745439663a4627771.html

相关推荐

  • arrays - Removing quotes from console log in JavaScript - Stack Overflow

    I'm trying to remove the printed single quotations which occur while running the following code. I

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信