This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hello(name) | |
{ | |
console.log("Hello "+ name) | |
} | |
hello('stuti') | |
// Hello stuti | |
hello(12) | |
// Hello 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function name (parameter) | |
{ | |
statements | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function something(){ | |
} | |
console.log(something()) // undefined | |
function notSomething(){ | |
return 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myName() | |
// My name is Stuti Chahuhan | |
function myName() { | |
console.log(`My name is Stuti Chauhan`) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let checkNumber = function check (num){ | |
return (num %2==0)?"even" : "odd" | |
} | |
console.log(checkNumber(50)) | |
// even |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Anonymous Function | |
let checkNumber = function (num){ | |
return (num %2==0)?"even" : "odd" | |
} | |
console.log(checkNumber(50)) | |
// even |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myName() | |
// ReferenceError: myName is not defined | |
let myName =function () { | |
console.log(`My name is Stuti Chauhan`) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
value: Any, | |
done: true|false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function * generatorFunction() | |
{ | |
console.log('first to execute'); | |
yield 'takes a pause'; | |
console.log(' printed after the pause'); | |
yield 'end of the function'; | |
} | |
const gen = generatorFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* generator() { | |
yield "some value"; | |
return "ends here"; | |
yield "will never execute"; | |
yield "never reach here" | |
} | |
var gen = generator() | |
console.log(gen.next()); | |
// { value: "some value", done: false } |