Code after return statement

Is it only me or is this normal?
in

function createHelper(def, fontData){
        var tHelper = document.createElementNS(svgNS,'text');
        tHelper.style.fontSize = '100px';
        tHelper.style.fontFamily = fontData.fFamily;
        tHelper.textContent = '1';
        if(fontData.fClass){
            tHelper.style.fontFamily = 'inherit';
            tHelper.className = fontData.fClass;
        } else {
            tHelper.style.fontFamily = fontData.fFamily;
        }
        def.appendChild(tHelper);
        var tCanvasHelper = document.createElement('canvas').getContext('2d');
        tCanvasHelper.font = '100px '+ fontData.fFamily;
        return tCanvasHelper;
        return tHelper;
    }

the second return generates a (of course correct) warning in my brower: “unreachable code after return statement”

the code never gets executed after the first return. so no point in writing the 2nd one

1 Like

Don’t use two return in your Function. Because when program meet first return, your function will exit without execute codes below it.

This is code in the ionic framework… not mine. The request is to the ionic maintainers to change the code.

This is the weirdest post I’ve ever seen here. No link, no issue on Github, passive-aggressive question. Did you discover a bug in the code, or just bad style you wanted to call out without calling it out?

Well I don’t know: a bug or at least very bad style.

Johan.

Where did you find this? A GitHub search across org:ionic-team finds nothing for me.

It’s in the generated file in the www/build directory.

I found it because Safari gives a warning at startup of the app: unreachable code

Johan.

In that case the code most likely belongs to a plugin you are using, not ionic. As far as I know, the generated file concats all the code together into a single file.

And that plugin is possibly bodymovin

1 Like