This code works fine in browser hosted JavaScript environment :
    function foo(a=true)
    {
        console.log(a)
    }
But doing the same in qml is giving syntax error. 
What might I be doing wrong ?
In QML, you should write the function as
function foo(a) {
    if (a === undefined) a = true
    console.log(a)
}
The syntax
function foo(a=true)
is not supported as this syntax was introduced in ECMA-262 6th edition while QML only implements the fifth edition (as of Qt 5.11).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With