-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
323 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const array = [1, 2, 3, 4, 5]; | ||
console.log(array.at(-2)); // 4 | ||
|
||
const string = '12345'; | ||
console.log(string.at(-2)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Employee { | ||
name = "John"; | ||
#age=35; | ||
constructor() { | ||
} | ||
|
||
#getAge() { | ||
return #age | ||
} | ||
|
||
} | ||
|
||
const employee = new Employee(); | ||
employee.name = "Jack"; | ||
employee.#age = 35; // Throws an error |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Employee{ | ||
name = "John"; | ||
static #employerName="Github" | ||
|
||
static #getEmployerName() { | ||
return #employerName | ||
} | ||
} | ||
const employee = new Employee(); | ||
employee.emp = "Jack"; | ||
employee.#employerName = 35; // Throws an error |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function processData(arrayData) { | ||
return arrayData.map(data => { | ||
try { | ||
const json = JSON.parse(data); | ||
return json; | ||
} catch (err) { | ||
throw new Error( | ||
`Data processing failed`, | ||
{cause: err} | ||
); | ||
} | ||
}); | ||
} | ||
|
||
processData({"one": 1, "two": 2}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const user = Object.create(null); | ||
user.age = 35; | ||
user.hasOwn('age'); // true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const user = { | ||
age: 35, | ||
hasOwnProperty: ()=> { | ||
return false; | ||
} | ||
}; | ||
|
||
user.hasOwn('age') // true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const regexPatter = /(Jack)/gd; | ||
const input = 'Authos: Jack, Alexander and Jacky'; | ||
const result = [...input.matchAll(regexPatter)]; | ||
console.log(result[0]); // ['Jack', 'Jack', index: 8, input: 'Authos: Jack, Alexander and Jacky', groups: undefined, indices: Array(2)] |