javascript - Get JSON parameters -
i need values of parameters of json model have.
my output returns:
console.log(this.model);
{ year:2017, month:08, day:05}
i need values , create object example date='2017-08-05'
.
depending on need it, use javascript template literal: https://developer.mozilla.org/en-us/docs/web/javascript/reference/template_literals
mynewobject.date = `${this.model.year}-${this.model.month}-${this.model.day}`;
if date values numbers , not strings, may need "0" pad them. there example here: how output integers leading zeros in javascript
Comments
Post a Comment