JavaScript - this key Word Tutorial Points (1)
Objective: Teach a set of basic concepts in the JavaScript programming language.
Create a function as a variable (function expression) that prints ‘Hello World’ to console and another function that accepts a variable. The argument passed to the second the function should be executed as a function inside the body. Call the second function passing the first function as the argument.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="XX-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tutorial point - Ex 01</title>
</head>
<body>
<script>
/*Create a function as a variable (function expression) that
prints ‘Hello World’ to console */
console.log("Hello World");
/*Create a function as a variable (function expression)
that prints ‘Hello World’ to console and another function
that accepts a variable. */
let i = "Hello";
//to opent the console pree Fn + F12
console.log( i + " SLIIT");
/* The argument passed to the second function should be executed as a function
inside the body.
Call the second function passing the first function as the argument.*/
//--01--
let printSecondWord = function(x){
console.log("Hello" + x);
}
printSecondWord (" Kamal");
//--02--
let printMe = function(y){
return "Hello " + y;
}
let display = function(y){
document.write(`<h1>${y}</h1>`);
}
display(printMe ("Sirin"));
</script>
</body>
</html>
Comments
Post a Comment