This file contains hidden or 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 multiply(a, b) { // takes a long time | |
| // to finish its job | |
| for(var i=0;i<10000000000;i++) { | |
| // SIMULATING WAIT TIME | |
| } | |
| return a * b; | |
| } | |
| function square(n) { // square function is | |
| // dependent on multiply |
This file contains hidden or 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 square(n) { // square function is | |
| console.log(n*n); | |
| } | |
| var callback = function() { | |
| square(5); | |
| } // this function which is not called immediately | |
| // but after "SOMETIME", is called "CALLBACK" in | |
| // JS |
This file contains hidden or 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
| var someFn = function() { | |
| console.log("..Hey there, I hope you are enjoying my website"); | |
| } // this function which is not called immediately | |
| // but after "SOMETIME", is called "CALLBACK" in | |
| // JS | |
| // THIS IS CALLED BACK | |
| // setTimeout(callback, 5000); // 5 * 1000ms | |
| setInterval(someFn, 5000); |
This file contains hidden or 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 square(n) { // square function is | |
| console.log(n*n); | |
| } | |
| function cass(s) { | |
| square(s); | |
| } | |
| /** | |
| * The following is incorrect, because you need to be |
This file contains hidden or 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
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <h1>This is my website</h1> | |
| <script> |
This file contains hidden or 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
| var list = [ | |
| { | |
| category: "trees" | |
| }, | |
| { | |
| category: "grass" | |
| }, | |
| ] | |
| function someFunction(category) { | |
| let newList = []; |
This file contains hidden or 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
| const student = { | |
| name: "manoj", | |
| age: 20, | |
| gender: "male", | |
| city: "foobar", | |
| class: "3rd semester of college", | |
| fees: { | |
| five: { | |
| amount: 100 | |
| }, |
This file contains hidden or 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
| const student = { | |
| name: "manoj", | |
| age: 20, | |
| marks: { | |
| chemistry: 90, | |
| maths: 100, | |
| physics: 85, | |
| hindi: 92 | |
| }, | |
| avg: function() { |
This file contains hidden or 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
| const student = { | |
| name: "manoj", | |
| avg: () => { | |
| let a = (1 + 2 + 3 + 4) / 4; | |
| console.log(a); | |
| } | |
| } | |
| student.adity = function() { | |
| console.log("Hi, I am Adity!!"); |
This file contains hidden or 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
| class Animal { // represents animal | |
| constructor(name, sound) { // used for initializing the object | |
| this.name = name; | |
| this.voice = sound; | |
| } | |
| makeSound() { | |
| console.log(this.voice + " 📢 ") | |
| } |