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
| { | |
| "employees":[ | |
| {"firstName":"John", "lastName":"Doe"}, | |
| {"firstName":"Anna", "lastName":"Smith"}, | |
| {"firstName":"Peter", "lastName":"Jones"} | |
| ] | |
| } |
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 filter = (...args) => args.filter(el => el === 1); | |
| console.log(filter(1, 2, 3)); // [1] |
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
| let oldArray = [1, 2, 3]; | |
| let newArray = [...oldArray, 4, 5]; | |
| // [ 1, 2, 3 ] | |
| console.log(oldArray); | |
| [ 1, 2, 3, 4, 5 ] | |
| console.log(newArray); | |
| oldArray.pop(); | |
| [ 1, 2 ] | |
| console.log(oldArray); | |
| [ 1, 2, 3, 4, 5 ] |
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 oldArray = [1, 2, 3]; | |
| const newArray = [...oldArray, 4, 5]; | |
| // [1, 2, 3, 4, 5] المصفوفة الجديدة هى; | |
| // يمكنك ايضًا إستخدامه مع objects | |
| const oldObject = { | |
| name: 'Kevin' | |
| }; | |
| const newObject = { | |
| ...oldObject, | |
| gender: 'Male' |
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 Person { | |
| name = 'Jeo'; | |
| } | |
| const person = new Person(); | |
| console.log(person.name); |
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 Person { | |
| constructor () { | |
| this.name = 'Jeo'; | |
| } | |
| } | |
| const person = new Person(); | |
| console.log(person.name); //طباعة الاسم |
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 Person(){ | |
| this.age = 0; | |
| setInterval(() => { | |
| this.age++; // this فى هذه الحالة تعود على person | |
| }, 1000); | |
| } | |
| var p = new Person(); |
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
| // فى حالة عدم وجود متغيرات | |
| let sayHello = () => { | |
| console.log("Hello"); | |
| } | |
| sayHello(); | |
| // فى حالة عدم وجود متغير واحد يمكنك حذف () | |
| sayHello = myName => { | |
| console.log("Hello " + myName); | |
| } | |
| sayHello("Jeo"); |
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
| // نفترض دالة لحساب جمع رقمين | |
| let sumTwoNumbers = ( x, y ) => { | |
| return x + y; | |
| } | |
| console.log( sumTwoNumbers(2,3) ); | |
| //يمكنك ايضًا كتابتها بهذا الشكل فى حالة كانت الدالة سطر واحد | |
| sumTwoNumbers = ( x, y ) => x + y; | |
| console.log( sumTwoNumbers(2,3) ); |
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 x = 10; | |
| x = 20; | |
| console.log(x); | |
| // سيحدث خطأ : TypeError: Assignment to constant variable. |
NewerOlder