+ 2

[SOLVED] How to set default values of variables in function?

I mean default values of variables like this: var abc = { cvb: "xcf" }

6th Jul 2020, 10:55 AM
Woolbex
Woolbex - avatar
3 Answers
+ 5
const func = (obj={'name':'Guest', 'age':100}) => { console.log(`${obj.name} is ${obj.age} years old! `) } func({'name':'Anonymous :-)','age':'1000'}) //Anonymous is 1000 years old! func() //Guest is 100 years old!
6th Jul 2020, 11:27 AM
Arnesh
Arnesh - avatar
+ 2
Arnesh, Thank you so much
6th Jul 2020, 11:42 AM
Woolbex
Woolbex - avatar
+ 2
Woolbex Welcome
6th Jul 2020, 11:55 AM
Arnesh
Arnesh - avatar