Skip to content

Instantly share code, notes, and snippets.

View suhailgupta03's full-sized avatar
:octocat:

Suhail Gupta suhailgupta03

:octocat:
View GitHub Profile
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
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
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);
function square(n) { // square function is
console.log(n*n);
}
function cass(s) {
square(s);
}
/**
* The following is incorrect, because you need to be
<html>
<head>
</head>
<body>
<h1>This is my website</h1>
<script>
var list = [
{
category: "trees"
},
{
category: "grass"
},
]
function someFunction(category) {
let newList = [];
const student = {
name: "manoj",
age: 20,
gender: "male",
city: "foobar",
class: "3rd semester of college",
fees: {
five: {
amount: 100
},
const student = {
name: "manoj",
age: 20,
marks: {
chemistry: 90,
maths: 100,
physics: 85,
hindi: 92
},
avg: function() {
const student = {
name: "manoj",
avg: () => {
let a = (1 + 2 + 3 + 4) / 4;
console.log(a);
}
}
student.adity = function() {
console.log("Hi, I am Adity!!");
class Animal { // represents animal
constructor(name, sound) { // used for initializing the object
this.name = name;
this.voice = sound;
}
makeSound() {
console.log(this.voice + " 📢 ")
}