I want to create some gauges, but my Gauge object remains undefined.
var doesntwork;
function create_gauge(name, id, min, max, title, label) {
name = new JustGage({
id: id,
value: 0,
min: min,
max: max,
donut: false,
gaugeWidthScale: 0.3,
counter: true,
hideInnerShadow: true,
title: title,
label: label,
decimals: 2
});
}
create_gauge(doesntwork, "g2", 0, 100, "Füllstand", "%");
console.log(doesntwork); //undefined
why? can't i pass variables to a function?
JustGageas welldoesntworkisundefined- a primitive. So if you modify it in the function asname, it has no effect on thedoesntworkvariable. Why don't you just return the result fromnew JustGagefrom the function?returnvalue.var a = {}; var b = a; b = {}; console.log(a === b); /*this is not true in JavaScript*/. What's the difference between passing by reference vs. passing by value?