Forum Discussion
- Philip_BairdCommunity ExpertHi Ocean, no, you can not do what you want. However, you can use the logical or operator as a type of null coalescing operator to assign a default value to a local var as such:
function CustomMethod(param1, param2)
{
var a = param1 || 'root';
var b = param2 || 100;
}
Regards,
Phil Baird - jose_pitaSuper ContributorThis is what I do in this cases:
function awesome(param1, param2)
{
if(param1 == undefined)
param1 = "whatever"
if(param2 == undefined)
param2 = 0;
}
awesome();
This way you don't need to worry about what you send in.
If you need to use this function on a keyword just send undefined as the parameters, not String type.- SerettaOccasional Contributor
thanks, that's just what I needed
Related Content
- 2 years ago
Recent Discussions
- 4 days ago
- 4 days ago