Skip to content

Instantly share code, notes, and snippets.

View makstyle119's full-sized avatar
🎯
Focusing

Mohammad Moiz Ali makstyle119

🎯
Focusing
View GitHub Profile
@makstyle119
makstyle119 / AssignAndCallFunctionInJavaScript.js
Created March 27, 2023 15:26
Assign And Call Function In JavaScript
let result = addNumbers(5, 7);
console.log(result); // logs 12 to the console
@makstyle119
makstyle119 / ReturnValuesInFunctions.js
Created March 27, 2023 15:19
Return Values in Functions
function addNumbers(num1, num2) {
return num1 + num2;
}
@makstyle119
makstyle119 / CallParameterFunctionInJavaScript.js
Created March 27, 2023 15:14
Call Parameter Function In JavaScript
addNumbers(5, 7); // logs 12 to the console
@makstyle119
makstyle119 / ParametersInFunctions.js
Created March 27, 2023 15:09
Parameters in Functions
function addNumbers(num1, num2) {
console.log(num1 + num2);
}
@makstyle119
makstyle119 / CallFunctionInJavaScript.js
Created March 27, 2023 15:05
Call Function In JavaScript
myFunction(); // logs "Hello, world!" to the console
@makstyle119
makstyle119 / SyntaxOfFunctionsInJavaScript.js
Created March 27, 2023 15:00
Syntax of Functions in JavaScript
function myFunction() {
console.log("Hello, world!");
}
@makstyle119
makstyle119 / ScopeOfVariables.js
Created March 26, 2023 10:06
Scope of Variables
let globalVariable = "I am global";
function myFunction() {
let localVariable = "I am local";
console.log(globalVariable); // "I am global"
console.log(localVariable); // "I am local"
}
myFunction();
console.log(globalVariable); // "I am global"
@makstyle119
makstyle119 / VariablesInJavaScript.js
Created March 26, 2023 09:47
Syntax of Variables in JavaScript
let myVariable = 5;
const myConstant = "Hello";
var myVar = true;
@makstyle119
makstyle119 / NestedScope.js
Created March 25, 2023 14:24
Nested Scope in js
let myVar = "Hello World!"; // global scope
function myFunction() {
let myVar = "Goodbye World!"; // local scope
console.log(myVar); // "Goodbye World!"
function innerFunction() {
console.log(myVar); // "Goodbye World!" (accesses the inner scope)
}
@makstyle119
makstyle119 / LocalScope.js
Created March 25, 2023 13:38
Local Scope in js
function myFunction() {
let myVar = "Hello World!"; // local scope
console.log(myVar); // "Hello World!"
}
myFunction();
console.log(myVar); // Throws an error: "myVar is not defined"