155
rated 0 times
[
162]
[
7]
/ answers: 1 / hits: 17499
/ 15 Years ago, sun, september 6, 2009, 12:00:00
In the code:
slider.init({
foo: bar
});
var slider={
init:function(data){
}
}
If I use data.foo
, I will get bar.
Supposing I have an optional variable called fish
which can be included in the JSON variable. If I reference data.fish
, I will be told that it is undefined or an error will be thrown or something. Is there a way that I can assign a default value to fish so that when I request data.fish
, even though it is not set in the parameter, I will get a default value?
More From » json