Revision: 67587
Updated Code
at October 9, 2014 17:50 by bboydflo
Updated Code
var value = false;
function gettersetter(bool){
// _args = array with function arguments
var _args = Array.prototype.slice.call(arguments);
if(_args.length == 0){
// if no arguments -> define get method
return value;
} else if(_args.length > 0){
value = bool;
}
}
How to use it:
// getter
var newValue = gettersetter();
// setter
gettersetter(true);
Revision: 67586
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 9, 2014 17:46 by bboydflo
Initial Code
var value = false;
function gettersetter(bool){
// _args = array with function arguments
var _args = Array.prototype.slice.call(arguments);
if(_args.length == 0){
// if no arguments -> define get method
return value;
} else if(_args.length > 0){
value = bool;
}
}
Initial URL
Initial Description
This example can be extended to include a more general object. here I get or set a single value
Initial Title
Simple getter and setter method depending on number of arguments
Initial Tags
Initial Language
JavaScript