js 改变数组中每条对象的属性值

js 改变数组中每条对象的属性值_第1张图片


<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>jstitle>
head>
<body>
  
  <script>
    var json = [
        {
      
          day: '2018-12-26 14:31:55'
        },
        {
      
          day: '2018-12-27 14:31:55'
        },
        {
      
          day: '2018-12-28 14:31:55'
        },
        {
      
          day: '2019-12-29 14:31:55'
        }
      ];



    for(let i in json){
      
      json[i].day=json[i].day.slice(0,10);  // 去掉时间,保留日期
    }
    console.log(json);
  script>
body>
html>

效果:
js 改变数组中每条对象的属性值_第2张图片

你可能感兴趣的:(js,前端,改变属性值,json,数据)