Javascript
Fleetingjavascript
Are ‘Arrow Functions’ and ‘Functions’ equivalent / interchangeable?
- Référence externe : https://stackoverflow.com/questions/34361379/are-arrow-functions-and-functions-equivalent-interchangeable
Are ‘Arrow Functions’ and ‘Functions’ equivalent / interchangeable?
Arrow functions and function declarations / expressions are not equivalent and cannot be replaced blindly. If the function you want to replace does not use this, arguments and is not called with new, then yes.
Arrow functions don’t have their own this or arguments binding. Instead, those identifiers are resolved in the lexical scope like any other variable. That means that inside an arrow function, this and arguments refer to the values of this and arguments in the environment the arrow function is defined in (i.e. “outside” the arrow function
ES2015 distinguishes between functions that are callable and functions that are constructable. If a function is constructable, it can be called with new, i.e. new User(). If a function is callable, it can be called without new (i.e. normal function call). Functions created through function declarations / expressions are both constructable and callable. Arrow functions (and methods) are only callable. class constructors are only constructable. If you are trying to call a non-callable function or to construct a non-constructable function, you will get a runtime error
inheritance and the prototype chain
- Référence externe : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
JavaScript objects are dynamic “bags” of properties (referred to as own properties).
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
When trying to access a property of an object, the property will not only be sought on the object but on the prototype of the object, the prototype of the prototype, and so on until either a property with a matching name is found or the end of the prototype chain is reached.
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
notation someObject.[Prototype]] is used to designate the prototype of someObject
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
[Prototype]] internal slot can be accessed and modified with the Object.getPrototypeOf() and Object.setPrototypeOf() functions respectively
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
is equivalent to the JavaScript accessor proto which is non-standard but de-facto implemented by many JavaScript engines
— https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
Notes pointant ici
- deno
- does nodejs wait for all promises before exiting? (blog)
- javascript fatigue
- javascript in browser
- nodejs
- number in javascript
- Reduce JavaScript payloads with tree shaking
- TC39
- trying to make programming easier
- Unique object identifier in javascript, like python id
- wasm-bindgen