def javascript code example
Example 1: javascript defer
//A script that will not run until after the page has loaded
<script src="demo.js" defer></script>
Example 2: javascript function
function myFunc(theObject) {
theObject.make = 'Toyota';
}
var mycar = {make: 'Honda', model: 'Accord', year: 1998};
var x, y;
x = mycar.make; // x gets the value "Honda"
myFunc(mycar);
y = mycar.make; // y gets the value "Toyota"
// (the make property was changed by the function)
Example 3: javascript function
// variable:
var num1;
var num2;
// function:
function newFunction(num1, num2){
return num1 * num2;
}
Example 4: function js
function myFunc(param) {
return param
}
console.log(myFunc("Hello World"))