javascript - Offirmo-team/wiki GitHub Wiki
Voir aussi navigateur, typescript, appli web, node.js, express.js, AngularJS, primus, grunt, mocha/chai, serveur, backbone, babel, développement web...
- +++ https://css-tricks.com/debouncing-throttling-explained-examples/ (legacy broken)
- An emoji guide for your commit messages https://gitmoji.carloscuesta.me/
Changements récents
- liste officielle https://www.ecma-international.org/publications/standards/Ecma-262-arch.htm
- proposals https://github.com/tc39/proposals/
- NEXT https://github.com/tc39/proposals/blob/master/finished-proposals.md
- 2020 https://2ality.com/2019/12/ecmascript-2020.html
- ES2019 https://illustrated.dev/es2019
- 2019 http://2ality.com/2018/02/ecmascript-2019.html
- finally https://frontarm.com/james-k-nelson/will-finally-run-quiz/
Références
- 2022 modern tutorial https://javascript.info/
- https://github.com/ericelliott/essential-javascript-links
- free ebook https://eloquentjavascript.net/
Meta
Blogs
Livres / cours
- https://justjavascript.com/
- http://blog.mediumequalsmessage.com/book-of-the-day-effective-javascript
Tests
Advocacy
- 2021 https://developers.slashdot.org/story/20/12/04/2139202/javascript-turns-25
- 2020 https://www.swyx.io/js-third-age/ 3rd age of JS
- 2020 https://developers.slashdot.org/story/20/10/25/0239229/does-python-need-to-change
- 2020 https://developers.slashdot.org/story/20/10/25/190257/java-geeks-discuss-the-war-for-the-browser-and-the-state-of-java-modularization
- -- 2020 https://www.zdnet.com/google-amp/article/another-one-line-npm-package-breaks-the-javascript-ecosystem/
- ~2019 https://www.swyx.io/js-tooling Why JavaScript Tooling Sucks
- 2018 competition: dart 2 https://medium.com/dartlang/dart-2-stable-and-the-dart-web-platform-3775d5f8eac7
- ++ 2018https://twitter.com/TheLarkInn/status/1006746626617008128
- +++ "Retiring Python as a Teaching Language" -> in favor of JavaScript http://prog21.dadgum.com/203.html
- 2018
- 2016
- 2015
- 2013
- x
- http://blog.codinghorror.com/javascript-the-lingua-franca-of-the-web/
- The JavaScript World Domination https://medium.com/@slsoftworks/javascript-world-domination-af9ca2ee5070
- language trends https://github.com/blog/2047-language-trends-on-github
- The JavaScript Monster- eating the world http://slides.com/flaki/js-eating-the-world#/
Feedback
- +++ https://deplinenoise.files.wordpress.com/2017/03/webtoolspostmortem.pdf
- ++ https://kryogenix.org/code/browser/everyonehasjs.html
- Problèmes ** MODULES ** fragmentation ** polyfills ** tooling ** fatigue ** speed https://benchmarksgame.alioth.debian.org/u64q/javascript.html
Fun
- https://dayssincelastjavascriptframework.com/
- http://gianlucaguarini.com/days-since-last-javascript-drama/
History
See https://gist.github.com/Offirmo/fac3c3064b4c239f874e39bb8933a71c
TOSORT
- "What you wish you'd known before getting into JavaScript?" https://news.ycombinator.com/item?id=17466391
- https://medium.freecodecamp.org/whats-the-difference-between-javascript-and-ecmascript-cba48c73a2b5
- complet http://superherojs.com/
- http://jstherightway.org/
- https://github.com/bebraw/jswiki/wiki/Beginner%27s-Resources
- http://www.sitepoint.com/learn-javascript-online/
- https://davidwalsh.name/essential-javascript-functions
- https://github.com/MostlyAdequate/mostly-adequate-guide to functional programming
- http://es6katas.org/
- http://perfectionkills.com/javascript-quiz-es6/
- JS specificity: reactor + event loop https://blog.insiderattack.net/event-loop-and-the-big-picture-nodejs-event-loop-part-1-1cb67a182810
- 2019 https://venturebeat.com/2019/01/29/hackerrank-developer-skills-report-2019/
- JavaScript: The World's Most Misunderstood Programming Language http://www.crockford.com/javascript/javascript.html
- intro to JS events https://www.permadi.com/tutorial/jsEventBubbling/index.html
- https://blog.neufund.org/why-we-have-banned-default-exports-and-you-should-do-the-same-d51fdc2cf2ad
- http://javascript.crockford.com/
- http://code.google.com/p/jslibs/wiki/JavascriptTips
- http://www.codeproject.com/Articles/580165/JavaScript-Best-Practices
- http://addyosmani.com/resources/essentialjsdesignpatterns/book/
- http://stackoverflow.com/questions/61088/hidden-features-of-javascript
- http://keith-wood.name/svg.html
- bootstrap http://twitter.github.io/bootstrap/getting-started.html
- outils
- https://github.com/ryanmcdermott/clean-code-javascript
- +++ https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5
- ++ clickjacking and iframes https://blog.innerht.ml/google-yolo/
- exercice http://escape.alf.nu/
- voir aussi Node.js#Sécurité et Appli web#Sécuritée
- ECMAScript 6 from an Attacker's Perspectiv http://www.slideshare.net/x00mario/es6-en
- http://davidwalsh.name/clickjacking
- CSP navigateur#content-security-policy
Libs
- Stanford Javascript Crypto Library http://crypto.stanford.edu/sjcl/
node.js ou simple navigateur
Voir node.js
Voir aussi appli web
(source https://developers.google.com/web/fundamentals/primers/modules)
-
https://developers.google.com/web/fundamentals/primers/modules
-
+++ https://hackcabin.com/post/managing-async-dependencies-javascript/
-
"Deep dive into the murky waters of script loading" https://www.html5rocks.com/en/tutorials/speed/script-loading/
-
https://eager.io/blog/everything-I-know-about-the-script-tag/
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>JS base 2</title>
<script src="http://ajax.googleapis.com/ajax/libs/xyz/1.9.1/xyz.js"></script>
</head>
<body>
<p>Javascript enabled page</p>
<script>
console.log("hello world");
</script>
<script type="module" src="module.js"></script>
<script type="module">
// or an inline script
import {helperMethod} from './providesHelperMethod.js';
helperMethod();
</script>
<noscript>Your browser either does not support JavaScript, or has it turned off.</noscript>
</body>
</html>
séquence d'exécution :
- http://stackoverflow.com/questions/1795438/load-and-execution-sequence-of-a-web-page
- http://stackoverflow.com/questions/8996852/load-and-execute-order-of-scripts
Priorités
- https://medium.com/reloading/preload-prefetch-and-priorities-in-chrome-776165961bbf
- https://developers.google.com/web/fundamentals/performance/resource-prioritization
- https://developers.google.com/web/updates/2019/02/priority-hints
- table https://addyosmani.com/blog/script-priorities/
https://michelenasti.com/2019/06/24/typescript-why-so-complicated.html
TRÈS intéressant
- https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3
- https://medium.com/javascript-scene/the-two-pillars-of-javascript-pt-2-functional-programming-a63aa53a41a4
- https://stackoverflow.com/questions/11502052/throwing-strings-instead-of-errors
- https://www.nczonline.net/blog/2009/03/10/the-art-of-throwing-javascript-errors-part-2/
-
http://blog.risingstack.com/node-js-best-practices/
- Always check for errors in callbacks
- Return on callbacks
- Use try-catch in sync code only
- Try to avoid this and new
- Create small modules
- Use good async patterns
- Handling operational errors : whatever, but log everything
- Handling programmer errors : Crash immediately
- Do not reinvent the wheel
- Use a style guide https://github.com/RisingStack/node-style-guide
http://blog.risingstack.com/node-js-best-practices-part-2/
- Consistent Style
- Enforce JSHint / JSCS Rules
- JS over JSON for configuration
- Dependency Injection
http://thenodeway.io/introduction/
- Structure
- Build Small Modules
- Build Modules to Serve a Single Purpose
- ... But Don't Get Carried Away
- Complexity via Composition
- Async
- Leverage I/O, Avoid Heavy Computation
- Invest in Clean Async
- Return Early
- Follow Standard Callback Patterns
- Get Help With Control Flow
- Community
- Leverage the Ecosystem (or: There’s a Module for That)
- Use the Best Tool for the Job
- Write Modules for Others to Read
- Build Modules for Others to Use
- Embrace the Community
- language guide : https://github.com/airbnb/javascript
- http://www.codethinked.com/preparing-yourself-for-modern-javascript-development
- keywords http://mathiasbynens.be/notes/reserved-keywords
- conseils http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/
- ES6
http://perfectionkills.com/understanding-delete/
http://blog.getify.com/on-the-nature-of-timers/
Objet très spécial
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
- http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript
- http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.1
- sort must always be used with a sort function:
[1, 10, 2].sort() -> [1, 10, 2]
- parseInt must always be passed a base, and should never be used in map(parseInt)
- http://www.toptal.com/javascript/interview-questions
- algorithmes https://github.com/trekhleb/javascript-algorithms
- Note : Meilleur exemple actuel : server_adapter_base
- http://raganwald.com/2014/07/09/javascript-constructor-problem.html
var ShutdownAgent = function ShutdownAgent(options) {
this.config = _.defaults({}, options, DEFAULT_CONFIG);
this.shutdown_steps = [];
};
ShutdownAgent.prototype.start = function() {
};
Discussion
function Derived() {
// Call the parent constructor
Parent.prototype.constructor.apply(this, arguments);
}
Derived.prototype = Object.create(Parent.prototype);
Derived.prototype.constructor = Derived;
Chaîne de prototypes :
- http://dailyjs.com/2012/05/28/js101-prototype-chains/
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#Inheritance
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Classical_inheritance_with_Object.create
Discussion
- http://alexsexton.com/blog/2013/04/understanding-javascript-inheritance
- http://ericleads.com/2013/02/fluent-javascript-three-different-kinds-of-prototypal-oo/
- http://ericleads.com/2013/01/javascript-constructor-functions-vs-factory-functions/
- private members http://javascript.crockford.com/private.html
- AMD https://github.com/amdjs/amdjs-api/wiki/AMD
- http://blog.startifact.com/posts/overwhelmed-by-javascript-dependencies.html
- "the module pattern" http://alistapart.com/article/the-design-of-code-organizing-javascript
- microlibs http://microjs.com/
- http://www.unheap.com/
- http://jster.net/
- http://darsa.in/
- pas mal http://www.thepetedesign.com/
- http://sindresorhus.com/bower-components/
- http://www.netmagazine.com/features/essential-javascript-top-five-script-loaders
- require.js
- http://browserify.org/
- https://github.com/amdjs/amdjs-api/wiki/Loader-Plugins polyfills, chargement conditionnel...
- http://stackoverflow.com/questions/11763458/how-to-optimally-serve-and-load-javascript-files
- http://stackoverflow.com/questions/5257923/how-to-load-local-script-files-as-fallback-in-cases-where-cdn-are-blocked-unavai/5522383#5522383
- http://raptorjs.org/ (eBay)
- yepnope.js a l'air simple et offre un excellent chargement conditionel. Il est inclus optionellement dans modernizr donc autant utiliser les 2 d'un coup
- http://stackoverflow.com/questions/296667/overriding-a-javascript-function-while-referencing-the-original
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
fun.call(thisArg[, arg1[, arg2[, ...]]])
fun.apply(thisArg[, argsArray])
- +++ https://blog.insiderattack.net/event-loop-and-the-big-picture-nodejs-event-loop-part-1-1cb67a182810
- http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#Event_loop
- There are 4 main types of queues that are processed by the native libuv event loop.
- Expired timers and intervals queue — consists of callbacks of expired timers added using setTimeout or interval functions added using setInterval.
- IO Events Queue — Completed IO events
- Immediates Queue — Callbacks added using setImmediate function
- Close Handlers Queue— Any close event handlers.
- 2 intermediate queues
- Next Ticks Queue — Callbacks added using process.nextTick function
- Other Microtasks Queue — Includes other microtasks such as resolved promise callbacks
- process.nextTick()
- setImmediate() https://devdocs.io/node/timers#timers_setimmediate_callback_args
- window.
- http://tech.pro/tutorial/1453/7-javascript-basics-many-developers-aren-t-using-properly
- http://know.cujojs.com/tutorials/aop/intro-to-aspect-oriented-programming
- http://net.tutsplus.com/tutorials/javascript-ajax/advanced-unit-testing-techniques-in-javascript/
- http://pixelhunter.me/post/54753803233/end-to-end-testing-with-zombie-js-mocha-js-and
http://berzniz.com/post/78260747646/5-javascript-debugging-tips-youll-start-using-today
console.log("hello world");
var bar = {name: 'kitten', status: 'playful'}
console.log(2,4,6,8,"foo",bar);
console.log("%s is %d years old.", "Bob", 42);
console.group("console levels tests");
console.log( "console.log");
console.debug("console.debug");
console.info( "console.info");
console.warn( "console.warn");
console.error("console.error");
console.groupEnd();
console.trace();
console.dir(bar);
console.assert(false);
http://www.html5rocks.com/en/tutorials/developertools/async-call-stack/
var para = document.getElementsByTagName('p')[0];
para.style.display = 'none';
getElementsByName
nodeName, nodeValue, nodeType, innerHTML, outerHTML
document.getElementById('mini-loader-errors').appendChild(document.createTextNode('Error loading the page !'));
document.getElementById('expected-rsrc-count').innerHTML = this.expected_rsrc_count;
document.getElementById('connected-rsrc-pane').style.display = 'none'; // 'block';
Voir page dédiée : XPath
- http://bitovi.com/blog/2010/10/a-crash-course-in-how-dom-events-work.html
- https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Events/Creating_and_triggering_events
- http://tech.pro/blog/1402/five-patterns-to-help-you-tame-asynchronous-javascript
- http://rowanmanning.com/posts/javascript-for-beginners-async/
- timeline http://animej.codeplex.com/
- later http://bunkat.github.io/later/
- ...
- +++ https://css-tricks.com/debouncing-throttling-explained-examples/
- +++ http://drupalmotion.com/article/debounce-and-throttle-visual-explanation
https://github.com/caolan/async
fs.stat(param, callback(err, result))
async.map(['file1','file2','file3'], fs.stat, function(err, results){
// results is now an array of stats for each file
});
fs.exists(param, callback(err, result))
async.filter(['file1','file2','file3'], fs.exists, function(results){
// results now equals an array of the existing files
});
async.parallel([
function(){ ... },
function(){ ... }
], callback);
async.series([
function(){ ... },
function(){ ... }
]);
async.waterfall([
function(callback){
callback(null, 'one', 'two');
},
function(arg1, arg2, callback){
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three');
},
function(arg1, callback){
// arg1 now equals 'three'
callback(null, 'done');
}
], function (err, result) {
// result now equals 'done'
});
- intro "Asynchronous Control Flow with Promises" http://howtonode.org/promises
- "An algebraic, Promises/A+ compliant implementation of Promises in node.js" https://github.com/mudge/pacta
- http://cryto.net/~joepie91/blog/2016/05/11/what-is-promise-try-and-why-does-it-matter/
- http://taoofcode.net/promise-anti-patterns/
Avancé
- perfs et choix : http://thanpol.as/javascript/promises-a-performance-hits-you-should-be-aware-of/
- patterns : http://modernjavascript.blogspot.co.uk/2013/09/promise-patterns.html
- http://blog.mediumequalsmessage.com/promise-deferred-objects-in-javascript-pt1-theory-and-semantics
Promise.resolve(value)
Promise.reject(new Error('Whatever'));
- http://tech.pro/tutorial/1669/21-javascript-parts-i-struggle-to-remember-
- http://mathiasbynens.be/notes/javascript-unicode
C++
- For node http://blog.scottfrees.com/getting-your-c-to-the-web-with-node-js^
- For browser https://www.leaningtech.com/cheerp/
http://www.2ality.com/2015/08/object-literals-es5.html
var obj = {
get foo() {
return Math.random();
},
set foo(value) {
console.log('SET foo = '+value);
},
};
Let’s use obj in a REPL:
> obj.foo
0.6029663002118468
> obj.foo
0.99780507478863
> obj.foo = 123;
SET foo = 123
Mieux vaut utiliser https://github.com/visionmedia/superagent et tests avec supertest
- dangereux!! https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
- https://cameronspear.com/blog/exactly-what-is-jsonp/
var jqxhr = $.ajax({
url: "http://tu1.utp.boursedeparis.fr:8081",
/*beforeSend: function ( xhr ) {
xhr.overrideMimeType("text/plain; charset=x-user-defined");
},*/
function( data, textStatus, jqXHR ) {
Q.error("[global_state_machine] success..." + textStatus);
ccf_client.attempt_event('_connection_success');
}*/
dataType: "jsonp",
})
//.always(function() { alert("complete"); })
//.done(function() { alert("success"); })
.fail(function( jqXHR, textStatus, errorThrown ) {
Q.error("[global_state_machine] error... " + textStatus + errorThrown);
ccf_client.attempt_event('_connection_failed');
});
??
- spec https://html.spec.whatwg.org/multipage/workers.html
- https://developer.mozilla.org/en-US/docs/Web/API/Worker
- https://www.inkling.com/read/javascript-definitive-guide-david-flanagan-6th/chapter-22/web-workers
"Worker threads run their code (and all imported scripts) synchronously from top to bottom, and then enter an asynchronous phase in which they respond to events and timers. If a worker registers an onmessage event handler, it will never exit as long as there is a possibility that message events will still arrive. But if a worker doesn’t listen for messages, it will run until there are no further pending tasks (such as download and timers) and all task-related callbacks have been called."
Page side :
var worker = new Worker("utils/loader.js");
worker.onmessage = function(e) {
var message = e.data; // Get message from event
console.log("URL contents: " + message); // Do something with it
}
worker.onerror = function(e) {
// Log the error message, including worker filename and line number
console.log("Error at " + e.filename + ":" + e.lineno + ": " +
e.message);
}
Worker side
// NOTE : Relative URLs are resolved relative to the URL that was passed to the Worker() constructor.
// importScripts() does not try to keep track of what scripts have already loaded and does nothing to prevent dependency cycles.
// importScripts() is a synchronous function: it does not return until all of the scripts have loaded and executed
importScripts("collections/Set.js", "collections/Map.js", "utils/base64.js");
postMessage()
onmessage
close()
Notes
- Vu expérimentalement : console.log() avec plusieurs paramètres ne fonctionne pas !
Utiliser require.js : http://requirejs.org/docs/api.html#webworker
- underscore.js / lo-dash / https://github.com/dtao/lazy.js
- conteneurs optimisés : http://monmohan.github.io/dsjslib/
- filtrage de tables https://github.com/crcn/sift.js
- hash maps https://github.com/flesler/hashmap
- https://github.com/bestiejs/json3
- https://github.com/airbnb/polyglot.js
- an arbitrary-precision integer arithmetic library https://github.com/vukicevic/crunch
Unicode
général
- ++ https://ponyfoo.com/articles/es6
- https://leanpub.com/setting-up-es6/read
- http://colintoh.com/blog/lightweight-es6-features précis
- http://www.2ality.com/2014/06/es6-multiple-return-values.html
- classes (WARNING considered harmful) http://javascriptplayground.com/blog/2014/07/introduction-to-es6-classes-tutorial/
- http://www.2ality.com/2014/09/es6-modules-final.html
- http://www.2ality.com/2014/10/es6-promises-api.html
- http://gajus.com/blog/2/the-definitive-guide-to-the-javascript-generators
- http://www.2ality.com/2014/12/es6-symbols.html
http://kangax.github.io/compat-table/es6/
Node
Browsers *
-
http://misterdai.yougeezer.co.uk/posts/2014/11/20/the-world-of-javascript-tomorrow-today/
-
Get ready for ECMAScript 6 http://k33g.github.io/2014/06/26/ES6-READY.html
- http://javascriptplayground.com/the-refactoring-tales/
- http://journal.crushlovely.com/post/88286828068/7-patterns-to-refactor-javascript-applications-value
- https://medium.com/the-javascript-collection/lets-write-fast-javascript-2b03c5575d9e
- http://arewefastyet.com/
http://robots.thoughtbot.com/replace-coffeescript-with-es6
démo https://dev.windows.com/en-us/microsoft-edge/testdrive/demos/chess/
- jshint
- jslint (utiliser plutôt jshint)
- couverture
- conformité
- erreurs
webkit-devtools-agent is king, node and browser. https://github.com/c4milo/node-webkit-agent
- Interface bien expliquée ici http://addyosmani.com/blog/taming-the-unicorn-easing-javascript-memory-profiling-in-devtools/
- Accès : http://c4milo.github.io/node-webkit-agent/26.0.1410.65/inspector.html?host=localhost:9999&page=0
Node
-
libs
-
détection d'erreurs
-
en ligne :
- http://www.jslint.com/
- http://blog.nodejitsu.com/scaling-isomorphic-javascript-code
- http://www.elijahmanor.com/2013/03/angry-birds-of-javascript-series.html
- http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
- http://berzniz.com/post/68001735765/javascript-hacks-for-hipsters
- http://flippinawesome.org/2013/11/25/fun-with-javascript-native-array-functions/
- http://www.cambus.net/emulators-written-in-javascript/
- http://flippinawesome.org/2013/06/03/javascript-inheritance-how-to-shoot-yourself-in-the-foot-with-prototypes/
- http://www.2ality.com/2013/06/triggering-events.html
- http://stackoverflow.com/questions/296667/overriding-a-javascript-function-while-referencing-the-original
- http://mathiasbynens.be/notes/reserved-keywords
- http://blog.pluralsight.com/2013/06/12/23-different-values-vs-underscore-js-is-functions/
- http://www.sitepoint.com/html5-summary-and-details/
- https://github.com/nbubna/grunt-init-vanilla
- http://dailyjs.com/tags.html#backgoog
- http://jcreamer898.github.io/bindr/
- http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/
- http://javascript.developpez.com/cours/outils-vraiment-utiles-pour-developpeurs-javascript/
- http://net.tutsplus.com/tutorials/javascript-ajax/cargo-culting-in-javascript/