-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
const namesArray = ['Abul', 'Kabul', 'Babul']; | ||
const numbersArray = [1, 2, 3, 4, 5]; | ||
console.log(namesArray); | ||
console.log(numbersArray); | ||
namesArray.map((name) => { | ||
console.log(name.charAt(4)); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
// primitive types | ||
// string | ||
// number | ||
// boolean | ||
// null | ||
// undefined | ||
let stringTypeVariable = 'This is a string'; | ||
let numberTypeVariable = 1234567890; | ||
let booleanTypeVariable = true; | ||
let nullTypeVariable = null; | ||
let undefinedTypeVariable = undefined; | ||
//stringTypeVariable = 5555; // Type 'number' is not assignable to type 'string'. | ||
stringTypeVariable.charAt(1); | ||
console.log(stringTypeVariable); | ||
// implicit types of typescript | ||
// when typescript automatically understand the type of the declared variable is known as the implicit types | ||
const implicitTypesVariable = 'This is a implicit stype variable'; | ||
console.log(implicitTypesVariable); | ||
// any type of tpescript | ||
let anyTypeVariable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
// primitive types | ||
// string | ||
// number | ||
// boolean | ||
// null | ||
// undefined | ||
let stringTypeVariable = 'This is a string'; | ||
let numberTypeVariable = 1234567890; | ||
let booleanTypeVariable = true; | ||
let nullTypeVariable = null; | ||
let undefinedTypeVariable = undefined; | ||
//stringTypeVariable = 5555; // Type 'number' is not assignable to type 'string'. | ||
stringTypeVariable.charAt(1); | ||
console.log(stringTypeVariable); | ||
// implicit types of typescript or inference | ||
// when typescript automatically understand the type of the declared variable is known as the implicit types | ||
const implicitTypesVariable = 'This is a implicit stype variable'; | ||
console.log(implicitTypesVariable); | ||
// any type of tpescript | ||
let anyTypeVariable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
// arrow function | ||
const addFunctionWithDefaultParameters = (number1 = 10, number2 = 20) => number1 + number2; | ||
const addTwoNumbersWithDefaultParameters = (number1 = 10, number2) => number1 + number2; | ||
const addTwoNumbers2WithDefaultParameters = (number1 = 10, number2) => number1 + (number2 !== null && number2 !== void 0 ? number2 : 0); | ||
console.log(addFunctionWithDefaultParameters()); | ||
console.log(addFunctionWithDefaultParameters(30, 50)); | ||
console.log(addFunctionWithDefaultParameters(50)); | ||
// console.log(addTwoNumbersWithDefaultParameters( 60)); // will not work | ||
console.log(addTwoNumbers2WithDefaultParameters(60)); | ||
// always use the default value to the last parameter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
var Grade; | ||
(function (Grade) { | ||
Grade[Grade["junior"] = 0] = "junior"; | ||
Grade[Grade["mid"] = 1] = "mid"; | ||
Grade[Grade["senior"] = 2] = "senior"; | ||
})(Grade || (Grade = {})); | ||
var Grade2; | ||
(function (Grade2) { | ||
Grade2["junior"] = "junior"; | ||
Grade2["mid"] = "mid"; | ||
Grade2["senior"] = "senior"; | ||
})(Grade2 || (Grade2 = {})); | ||
const rahim = { | ||
name: 'Rahim', | ||
age: 25, | ||
grade: 1 | ||
}; | ||
const rahima = { | ||
name: 'Rahim', | ||
age: 25, | ||
grade: Grade.senior | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use strict"; | ||
// normal function | ||
function addNumbersNormalFunction(number1, number2) { | ||
return number1 + number2; | ||
} | ||
// arrow function | ||
const addNumbersArrowFunction = (number1, number2) => number1 + number2; | ||
const arrayOfNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; | ||
// callback function | ||
const squareCallbackFunction = arrayOfNumbers === null || arrayOfNumbers === void 0 ? void 0 : arrayOfNumbers.map((number) => number * number); | ||
const qubeCallbackFunction = arrayOfNumbers === null || arrayOfNumbers === void 0 ? void 0 : arrayOfNumbers.map((number) => number * number * number); | ||
console.log(addNumbersNormalFunction(1, 2)); | ||
console.log(addNumbersArrowFunction(10, 20)); | ||
console.log(squareCallbackFunction); | ||
console.log(qubeCallbackFunction); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
const course = 'Next level Web Developer'; | ||
const course2 = 'Next level Web Developer is learning'; | ||
const course3 = 'Next level Web Developer needs next level dedication'; | ||
console.log(course); | ||
console.log(course2); | ||
console.log(course3); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
const developer = { | ||
name: 'Montasim', | ||
expertise: 'JavaScript', | ||
experience: 5, | ||
leadershipExperience: 2 | ||
}; | ||
console.log(developer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
const userLiterelType = { | ||
name: 'Montasim', | ||
company: 'My MedicalHUB International Ltd.', | ||
age: 25, | ||
isMarried: true, | ||
}; | ||
const user2LiterelType = { | ||
name: 'Shuvo', | ||
company: 'My MedicalHUB International Ltd.', | ||
age: 25, | ||
isMarried: false, | ||
}; | ||
console.log(userLiterelType); | ||
console.log(user2LiterelType); | ||
// user2LiterelType?.company = 'Enosis'; // can not update |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
// when a function is being used inside an object is called method | ||
const objectWithMethod = { | ||
name: 'Shuvo', | ||
balance: 10000, | ||
addBalance(money) { | ||
return `My New Balance: ${this.balance + money}`; | ||
} | ||
}; | ||
console.log(objectWithMethod.addBalance(1000)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
const userModifierReadonly = { | ||
name: 'Montasim', | ||
company: 'My MedicalHUB International Ltd.', | ||
age: 25, | ||
isMarried: true, | ||
}; | ||
// userModifierReadonly?.company = 'Enosis'; // can not update | ||
console.log(userModifierReadonly); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
function throwError(message) { | ||
throw new Error(message); | ||
} | ||
throwError('This file should not be compiled'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
const searchName = (value) => { | ||
if (value === null) { | ||
console.log('Search result not found'); | ||
} | ||
else { | ||
console.log('Searching...'); | ||
} | ||
}; | ||
searchName('Montasim'); | ||
searchName(null); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
var _a, _b; | ||
const isAuthenticatedUser = undefined; | ||
const isAuthenticatedUser2 = ''; | ||
const userName = isAuthenticatedUser !== null && isAuthenticatedUser !== void 0 ? isAuthenticatedUser : 'Guest User'; | ||
const userName2 = isAuthenticatedUser ? isAuthenticatedUser : 'Guest User'; | ||
const userName3 = isAuthenticatedUser2 !== null && isAuthenticatedUser2 !== void 0 ? isAuthenticatedUser2 : 'Guest User'; | ||
const userName4 = isAuthenticatedUser2 ? isAuthenticatedUser2 : 'Guest User'; | ||
console.log(userName); | ||
console.log(userName2); | ||
console.log(userName3); | ||
console.log(userName4); | ||
const manush1 = { | ||
name: 'Montasim', | ||
age: 22, | ||
address: { | ||
city: 'No City', | ||
road: 'No Road', | ||
} | ||
}; | ||
const home = (_b = (_a = manush1 === null || manush1 === void 0 ? void 0 : manush1.address) === null || _a === void 0 ? void 0 : _a.home) !== null && _b !== void 0 ? _b : 'No Home'; | ||
console.log(home); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
const userObject = { | ||
name: 'Montasim', | ||
age: 25, | ||
isMarried: true, | ||
wife: 'Karobi' | ||
}; | ||
const userObjectInComplete = { | ||
name: 'Montasim', | ||
age: 25, | ||
isMarried: true, | ||
wife: 'Karobi' | ||
}; | ||
const userObjectWithOptionalType = { | ||
name: 'Montasim', | ||
age: 25, | ||
isMarried: true, | ||
}; | ||
const userObjectWithSpecificValue = { | ||
name: 'Montasim', | ||
company: 'My MedicalHUB International Ltd.', | ||
age: 25, | ||
isMarried: true, | ||
}; | ||
console.log(userObject); | ||
console.log(userObjectInComplete); | ||
console.log(userObjectWithOptionalType); | ||
console.log(userObjectWithSpecificValue); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
const greetFriendsFunction = (...friends) => friends === null || friends === void 0 ? void 0 : friends.forEach(friend => console.log(`Hello ${friend}`)); | ||
const greetFriendsFunction2 = (...friends) => { | ||
return friends === null || friends === void 0 ? void 0 : friends.map(friend => { | ||
return `Hello ${friend}`; | ||
}); | ||
}; | ||
const greetFriendsFunction3 = (friend1, ...friends) => { | ||
friends === null || friends === void 0 ? void 0 : friends.forEach(friend => console.log(`Hello ${friend}`)); | ||
}; | ||
const myBestFriendsObject = { | ||
name: 'Rahim', | ||
age: 25, | ||
}; | ||
const { name: myBestFriendName } = myBestFriendsObject; | ||
console.log(myBestFriendName); | ||
greetFriendsFunction('Rahim', 'Karim', 'Abul'); | ||
console.log(greetFriendsFunction2('Rahim', 'Karim', 'Abul')); | ||
greetFriendsFunction3('Rahim', 'Karim', 'Abul'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
const myFriendsArray = ['Rahim', 'Karim', 'Abul']; | ||
const newFriendsArray = ['Salam', 'Kalam', 'Rubel']; | ||
myFriendsArray === null || myFriendsArray === void 0 ? void 0 : myFriendsArray.push(...newFriendsArray); | ||
console.log(myFriendsArray); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict"; | ||
const userTuple = [420, 'Rahim']; | ||
console.log(userTuple); | ||
// when necessity of key and value pair tuple is used for that |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
const age = 22; | ||
if (age >= 18) { | ||
console.log('You are an adult'); | ||
} | ||
else { | ||
console.log('You are not an adult'); | ||
} | ||
const isAdult = age >= 18 ? 'yes' : 'no'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"use strict"; | ||
const crushObject1 = { | ||
name: 'Karobi', | ||
age: 25, | ||
profession: 'Housewife', | ||
address: 'Rangpur', | ||
}; | ||
const crushObject2 = { | ||
name: 'Sharmin', | ||
age: 25, | ||
profession: 'Housewife', | ||
address: 'Rangpur', | ||
}; | ||
const calculate = (number1, number2, operation) => { | ||
return operation(number1, number2); | ||
}; | ||
console.log(calculate(10, 20, (x, y) => x + y)); | ||
console.log(calculate(10, 20, (x, y) => x - y)); | ||
console.log(calculate(10, 20, (x, y) => x * y)); | ||
console.log(calculate(10, 20, (x, y) => x / y)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
const newDeveloperUnionType = { | ||
name: 'Montasim', | ||
expertise: 'JavaScript', | ||
experience: 5 | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use strict"; | ||
const getMyCarSpeed = (speed) => { | ||
if (typeof speed === 'number') { | ||
return speed; | ||
} | ||
else if (typeof speed === 'string') { | ||
return parseInt(speed); | ||
} | ||
else { | ||
return 0; | ||
} | ||
}; | ||
getMyCarSpeed(100); | ||
getMyCarSpeed('100 kmh^-1'); | ||
getMyCarSpeed(true); |