Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 507 Bytes

default-parameters.md

File metadata and controls

29 lines (24 loc) · 507 Bytes

Default Parameters

Define valores como padrão dentro de uma função

<!DOCTYPE html>
<html>
<head>
    <title>Default Parameters</title>
</head>
<body>
</body>

<script>
//ES5
    function love(learn, read){
        learn = learn || "ES6";
        read = read || "about React";
        console.log("I love " + learn +"and " + read + "!");
    }

//ES6
    function loveES6(learn = "ES6", read = "about React"){
        console.log(`I love ${learn} and ${read}!`);
    }
</script>
</html>