informatique:javascript
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| informatique:javascript [24/11/2024 12:38] – [Browser Detection and Cross Browser Support] cyrille | informatique:javascript [11/06/2025 16:54] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. 114.119.143.104 | ||
|---|---|---|---|
| Ligne 15: | Ligne 15: | ||
| * [[http:// | * [[http:// | ||
| * [[https:// | * [[https:// | ||
| - | * [[https:// | ||
| News, listes d' | News, listes d' | ||
| Ligne 25: | Ligne 24: | ||
| - JavaScript performance playground: jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks. | - JavaScript performance playground: jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks. | ||
| + | ===== Syntaxe ===== | ||
| + | |||
| + | Il y a plein d' | ||
| + | |||
| + | * https:// | ||
| + | |||
| + | |||
| + | **Template Literals**: | ||
| + | |||
| + | <code javascript> | ||
| + | const name = " | ||
| + | const greeting = `Hello, ${name}! | ||
| + | Welcome to JavaScript tips!`; | ||
| + | |||
| + | console.log(greeting); | ||
| + | </ | ||
| + | |||
| + | **The Spread Operator**: | ||
| + | |||
| + | <code javascript> | ||
| + | const arr1 = [1, 2]; | ||
| + | const arr2 = [3, 4]; | ||
| + | const combined = [...arr1, ...arr2]; // [1, 2, 3, 4] | ||
| + | |||
| + | const user = { name: " | ||
| + | const updatedUser = { ...user, age: 26 }; // { name: " | ||
| + | </ | ||
| + | |||
| + | **Short-Circuit Evaluation**: | ||
| + | |||
| + | <code javascript> | ||
| + | const isLoggedIn = true; | ||
| + | const welcomeMessage = isLoggedIn && " | ||
| + | console.log(welcomeMessage); | ||
| + | |||
| + | const username = null; | ||
| + | const displayName = username || " | ||
| + | console.log(displayName); | ||
| + | </ | ||
| + | |||
| + | or **Use ||= Operator for Default Assignment** | ||
| + | |||
| + | <code javascript> | ||
| + | let count; | ||
| + | count ||= 10; | ||
| + | console.log(count); | ||
| + | </ | ||
| + | |||
| + | **Destructuring**: | ||
| + | |||
| + | <code javascript> | ||
| + | // Before destructuring | ||
| + | const user = { name: " | ||
| + | const name = user.name; | ||
| + | const age = user.age; | ||
| + | |||
| + | // Using destructuring | ||
| + | const { name, age } = user; | ||
| + | console.log(name, | ||
| + | </ | ||
| + | |||
| + | **Optional Chaining for Safer Access**: | ||
| + | |||
| + | <code javascript> | ||
| + | const user = { profile: { email: " | ||
| + | |||
| + | console.log(user? | ||
| + | console.log(user? | ||
| + | </ | ||
| + | |||
| + | **Default Parameters**: | ||
| + | |||
| + | <code javascript> | ||
| + | function greet(name = " | ||
| + | return `Hello, ${name}!`; | ||
| + | } | ||
| + | |||
| + | console.log(greet()); | ||
| + | console.log(greet(" | ||
| + | </ | ||
| + | |||
| + | **Array Methods: Map, Filter, and Reduce**: | ||
| + | |||
| + | <code javascript> | ||
| + | const numbers = [1, 2, 3, 4]; | ||
| + | |||
| + | // Transform each element with map | ||
| + | const doubled = numbers.map(num => num * 2); // [2, 4, 6, 8] | ||
| + | |||
| + | // Filter elements based on a condition | ||
| + | const evens = numbers.filter(num => num % 2 === 0); // [2, 4] | ||
| + | |||
| + | // Aggregate values with reduce | ||
| + | const sum = numbers.reduce((acc, | ||
| + | </ | ||
| + | |||
| + | More tips: | ||
| + | * https:// | ||
| + | * https:// | ||
| ===== Tools ===== | ===== Tools ===== | ||
| Ligne 45: | Ligne 143: | ||
| http:// | http:// | ||
| + | |||
| + | ==== BlockNote ==== | ||
| + | |||
| + | https:// | ||
| + | |||
| + | https:// | ||
| ==== markItUp! ==== | ==== markItUp! ==== | ||
| Ligne 424: | Ligne 528: | ||
| Voir aussi: | Voir aussi: | ||
| - | * [[/informatique/php/laravel# | + | * UI Suite for Vue.js https:// |
| + | * [[informatique: | ||
| * collection de scripts et plugins : http:// | * collection de scripts et plugins : http:// | ||
| * [[https:// | * [[https:// | ||
| Ligne 796: | Ligne 901: | ||
| ==== Promise ==== | ==== Promise ==== | ||
| + | |||
| + | Sur la page [[/ | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| ==== WebSockets ==== | ==== WebSockets ==== | ||
| Ligne 876: | Ligne 986: | ||
| }); | }); | ||
| </ | </ | ||
| + | |||
| + | === shallow copy deep copy === | ||
| + | |||
| + | Shallow Copy ne copie pas les valeurs références, | ||
| + | |||
| + | Shallow copy: | ||
| + | <code javascript> | ||
| + | // Using the Spread Operator (...): | ||
| + | const shallowCopy = { ...originalObject }; | ||
| + | // Using Object.assign(): | ||
| + | const shallowCopy = Object.assign({}, | ||
| + | </ | ||
| + | Deep copy: | ||
| + | <code javascript> | ||
| + | const deepCopy = JSON.parse(JSON.stringify(original)); | ||
| + | </ | ||
| + | |||
| + | * https:// | ||
| + | |||
informatique/javascript.1732448335.txt.gz · Dernière modification : de cyrille
