created: 20221110145611678 creator: Octt modified: 20240130124051881 modifier: Octt tags: Development $:/i18n:en Web title: JavaScript ''JavaScript'', or "JS", is an high-level programming language. It constitutes a core technology of the Web, sitting optionally alongside HTML and CSS. In recent years, it has gotten more and more popular even for desktop app and backend development. <<^wikipediaframe JavaScript>> * [[Ecma International TC39|https://tc39.es/]] - Committee maintaining JS specifications * [[aem1k|https://aem1k.com/]] --- //JavaScript Hacks and Creative Coding Created by Martin Kleppe aka @aemkei.// --- <<[# Git"https://github.com/aemkei/aemkei.github.io">> !!! ''Resources'' * [[The Modern JavaScript Tutorial (javascript.info)|https://javascript.info/]] --- //How it's done now. From the basics to advanced topics with simple, but detailed explanations.// * <> --- //helps you learn JavaScript programming from scratch quickly and effectively// * //''[[JSFuck|https://jsfuck.com/]]'' is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.// --- <<[# Git+Guide "https://github.com/aemkei/jsfuck">> * [[Which equals operator (== vs ===) should be used in JavaScript comparisons?|https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons]] ("Good and bad twins") --- `==` is bad unless explicitly needed, since it does type-coercion. ** [[In theory === is faster, no type conversion takes place. Practically there's no performance difference.|https://stackoverflow.com/questions/12332855/which-javascript-equality-operator-or-is-faster]] ** [[JavaScript-Equality-Table|https://dorey.github.io/JavaScript-Equality-Table/unified/]] - <<[ "[[Git|https://github.com/dorey/JavaScript-Equality-Table]]">> * [[Environment detection: node.js or browser|https://stackoverflow.com/a/57774317]] * [[Superpacking JS Demos|https://web.archive.org/web/20120919185414/http://daeken.com/superpacking-js-demos]] * [["Illegal invocation" errors in JavaScript|https://mtsknn.fi/blog/illegal-invocations-in-js/]] --- //The error is thrown when calling a function whose `this` keyword isn't referring to the object where it originally did (when the context of the function is lost)// * [[Does JavaScript have a method like "range()" to generate a range within the supplied bounds?|https://stackoverflow.com/questions/3895478/does-javascript-have-a-method-like-range-to-generate-a-range-within-the-supp]] --- `[...Array(5).keys()]` * [[Listen for triple clicks in JavaScript|https://stackoverflow.com/questions/6480060/how-do-i-listen-for-triple-clicks-in-javascript#6480113]] * [[Fastest method to escape HTML tags as HTML entities?|https://stackoverflow.com/questions/5499078/fastest-method-to-escape-html-tags-as-html-entities]] --- in the browser, `(html) => { var escape = document.createElement('textarea'); escape.textContent = html; return escape.innerHTML; }` * [[Get a random item from a JavaScript array|https://stackoverflow.com/questions/5915096/get-a-random-item-from-a-javascript-array#5915122]] : [[Getting a random value from a JavaScript array|https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array]] --- `item = items[Math.floor(Math.random() * items.length)];` * [[Simplest code for array intersection in javascript|https://stackoverflow.com/questions/1885557/simplest-code-for-array-intersection-in-javascript#1885569]] --- `arrayNew = array1.filter(value => array2.includes(value));` * [[Why is 'for (... in ...)' with arrays considered bad practice in JavaScript?|https://stackoverflow.com/questions/2265167/why-is-forvar-item-in-list-with-arrays-considered-bad-practice-in-javascript]] --- use `for (... of ...)` to iterate for values, the `in` form should only be used to iterate over indices * [[Why is extending native objects a bad practice?|https://stackoverflow.com/questions/14034180/why-is-extending-native-objects-a-bad-practice]] --- it breaks everything for some objects. ** see [[https://eslint.org/docs/latest/rules/no-extend-native]] * [[What does ~~ ("double tilde") do in Javascript?|https://stackoverflow.com/questions/4055633/what-does-double-tilde-do-in-javascript]] ; [[What is the "double tilde" (~~) operator in JavaScript? [duplicate]|https://stackoverflow.com/questions/5971645/what-is-the-double-tilde-operator-in-javascript]] --- double NOT logical operator, useful shorter and faster alternative to `Math.floor` for small numbers * [[How to convert uint8 Array to base64 Encoded String?|https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/66046176#66046176]] * [[What is the JavaScript version of sleep()?|https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep#39914235]] --- `await new Promise(r => setTimeout(r, milliseconds));` * [[Convert letter to number in JavaScript|https://stackoverflow.com/questions/27877197/convert-letter-to-number-in-javascript]] (or parse a String that contains a number and happens to contain letters as a Number) --- <> * [[JavaScript Regex Replace Tutorial|https://www.javascripttutorial.net/javascript-regex/replace/]] * [[Send POST data using XMLHttpRequest|https://stackoverflow.com/questions/9713058/send-post-data-using-xmlhttprequest]] * [[fetch API [and comparison with XMLHttpRequest]|https://davidwalsh.name/fetch]] * [[How do I upload a file with the JS fetch API?|https://stackoverflow.com/questions/36067767/how-do-i-upload-a-file-with-the-js-fetch-api#comment98412965_36082038]] --- pass the `file` object to the body, do NOT set Content-Type header * [[How to Use Fetch with async/await|https://dmitripavlutin.com/javascript-fetch-async-await/]] * [[String indexOf()|https://www.w3schools.com/jsref/jsref_indexof.asp]] * [[Array.prototype.splice()|https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice]], [[JavaScript Array splice() (W3S)|https://www.w3schools.com/jsref/jsref_splice.asp]] --- //changes the contents of an array by removing or replacing existing elements and/or adding new elements in place//, useful alternative for a nonexistant remove function, with `.splice(index, amountToRemove)` * <> --- //used to merge two or more arrays, does not change the existing arrays but instead returns a new one// * [[XMLHttpRequest|https://www.w3schools.com/xml/xml_http.asp]] ** <> * <> --- //(t,i,x,y) => "creative code golfing"// --- <<[# Git"https://github.com/aemkei/tixy">> !!! ''Tools'' * [[jsPerf|https://jsperf.app/]] - //online JavaScript performance benchmark// - <<[ "[[Git|https://github.com/rd13/jsperf.app]]">> ** Old source code: [[v2|https://github.com/jsperf]], [[v1|https://github.com/mathiasbynens/jsperf.com]] * [[MeasureThat.net|https://www.measurethat.net/]] - //measure performance of JavaScript code// - <<[ "[[Git|https://github.com/thecoderok/MeasureThat.net]]">> * [[UglifyJS|https://lisperator.net/uglifyjs/]] - //JavaScript parser / mangler / compressor / beautifier// - <<[ "[[Git|https://github.com/mishoo/UglifyJS]]">> ** <> * <> * [[aaencode demo|https://utf-8.jp/public/aaencode.html]] --- //Encode any JavaScript program to Japanese style emoticons (^_^)// * [[jjencode demo|https://utf-8.jp/public/jjencode.html]] --- encode JS using limited symbols