779 Matching Annotations
  1. Jan 2022
    1. You basically did var a = promise.then(…); var b = promise.catch(…); creating a branch in the chain. If promise is getting rejected now, the catch callback will be called and b will be a fulfilled promise just fine, but the a promise is getting rejected too and nobody handles that. Instead, you should use both arguments of then and write Requirement.create({id: id, data: req.body.data, deleted: false}) .then(requirement => { res.json(requirement); }, reason => { let err = {'error': reason}; res.json(err); });
    1. but has a critical difference: the expression console.log("before 2"); does not and cannot depend on the resolved value result. The throw propagates through all chained promises, and when it stops, there is no remaining undefined behavior! No piece of code is left in an unclear state, and therefore there is no reason to crash.
    2. Node is entirely at liberty to limit the design the same way we crash the process on errors (which browsers do not).
  2. www.npmjs.com www.npmjs.com
    1. co(function* () {  var result = yield Promise.resolve(true);  return result;}).then(function (value) {  console.log(value);}, function (err) {  console.error(err.stack);});
    2. Generator based control flow goodness for nodejs and the browser, using promises, letting you write non-blocking code in a nice-ish way.
    1. Yes, precisely because I've been involved in maintaining codebases built without real full stack frameworks is why I say what I said.The problem we have in this industry, is that somebody reads these blog posts, and the next day at work they ditch the "legacy rails" and starts rewriting the monolith in sveltekit/nextjs/whatever because that's what he/she has been told is the modern way to do full stack.No need to say those engineers will quit 1 year later after they realize the mess they've created with their lightweight and simple modern framework.I've seen this too many times already.It is not about gatekeeping. It is about engineers being humble and assume it is very likely that their code is very unlikely to be better tested, documented, cohesive and maintained than what you're given in the real full stack frameworks.Of course you can build anything even in assembler if you want. The question is if that's the most useful thing to do with your company's money.
    1. The encodeURIComponent() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character
      • ENCODEURI
    1. Decoding query parameters from a URL decodeURIComponent cannot be used directly to parse query parameters from a URL. It needs a bit of preparation. function decodeQueryParam(p) { return decodeURIComponent(p.replace(/\+/g, ' ')); } decodeQueryParam('search+query%20%28correct%29'); // 'search query (correct)'
      • DECODEURI
    1. The old versions of JavaScript had no import, include, or require, so many different approaches to this problem have been developed. But since 2015 (ES6), JavaScript has had the ES6 modules standard to import modules in Node.js, which is also supported by most modern browsers. For compatibility with older browsers, build tools like Webpack and Rollup and/or transpilation tools like Babel can be used.
      • JAVASCRIPT: IMPORT
  3. developer.mozilla.org developer.mozilla.org
    1. import La sentencia import se usa para importar funciones que han sido exportadas desde un módulo externo. Por el momento, esta característica sólo está comenzando a ser implementada de forma nativa en los navegadores. Está implementada en muchos transpiladores, tales como Typescript y Babel, y en empaquetadores como Rollup y Webpack.
      • JAVASCRIPT: IMPORT
    1. Just last year Grunt was effectively dethroned by Gulp. And now, just as Gulp and Browserify are finally reaching critical mass, Webpack threatens to unseat them both. Is there truly a compelling reason to change your front-end build process yet again?
      • CONTINUOS CHANGE!
      • reinventing the wheel
    1. IE will block appending any element created in a different window context from the window context that the element is being appending to. var childWindow = window.open('somepage.html'); //will throw the exception in IE childWindow.document.body.appendChild(document.createElement('div')); //will not throw exception in IE childWindow.document.body.appendChild(childWindow.document.createElement('div'));
      • IMPORTANT
    1. The actual problem is that when the page is loaded with document.write, IE will always load inline javascript blocks before external javascript files, regardless of which one get defined first. This is described in dynamicdrive.com/forums/blog.php?bt=173 (section II). A good workaround is to put everything as external javascript files. – sayap Jan 5 '12 at 5:05
      • IMPORTANT
  4. Dec 2021
    1. The first thing you need to know is that JavaScript and Java are two totally different languages. If you are trying to learn JavaScript, you cannot follow instructions intended for Java. The best way I've seen this explained is: "Java is to JavaScript as car is to carpet."
      • "Java is to JavaScript as car is to carpet."
    1. A JavaScript wrapper for the Hypothesis API The HelloWorldAnnotated example uses functions from a library, hlib, to post an annotation to the Hypothesis service.
      • AT LAST!
      • SEE
    1. function intersperse<T>(this: T[], mkT: (ix: number) => T): T[] { return this.reduce((acc: T[], d, ix) => [...acc, mkT(ix), d], []).slice(1); }
    1. A Map of root-level context key-value pairs to supply to the component
    1. Welcome to Accessibility WeeklyA weekly dose of web accessibility to help you bring it into your everyday work. Delivered to your inbox each Monday, curated by David A. Kennedy.

      a11y Weekly is about web accessibility. How to make the web user friendly to everyone.

  5. Nov 2021
    1. querySelector is the newer feature. getElementById is better supported than querySelector. querySelector is better supported than getElementsByClassName. querySelector lets you find elements with rules that can't be expressed with getElementById and getElementsByClassName

      Which is better?

      document.querySelector() or document.getElementById()

    1. arr.sort([compareFunction]) 参数 compareFunction 可选 用来指定按某种顺序进行排列的函数。如果省略,元素按照转换为的字符串的各个字符的Unicode位点进行排序。

      可以用箭头函数 arr.sort((a,b)=>a-b)

    1. 默认情况下,sort() 方法将按字母和升序将值作为字符串进行排序。
    2. sort() 方法对数组的项目进行排序。
    1. 比如你有一个有值的数组,你想去 map 遍历每一项,这时使用箭头函数非常理想: JavaScript 代码: 12const words = ['hello', 'WORLD', 'Whatever'];const downcasedWords = words.map((word) => word.toLowerCase());
    2. 如果您尝试使用内联单行表达式语法,但您返回的值是对象字面量。您可能会认为这看起来应该是这样的: JavaScript 代码: 1(name, description) => {name: name, description: description}; 问题是这种语法比较含糊不清,容易引起歧义 : 看起来好像你正试图创建一个传统的函数体。 如果你碰巧想要一个对象的单个表达式,请用括号包裹该对象: JavaScript 代码: 1(name, description) => ({ name: name, description: description }); 或者就是直接用 return 123(name, description) => { return { name: name, description: description };};

      箭头函数返回值为对象时的处理方法

    1. 如果要返回一个对象,就要注意,如果是单表达式,这么写的话会报错: // SyntaxError: x => { foo: x } 因为和函数体的{ ... }有语法冲突,所以要改为: // ok: x => ({ foo: x })
    2. 参数不是一个,就需要用括号()括起来
    3. 箭头函数有两种格式,一种像上面的,只包含一个表达式,连{ ... }和return都省略掉了。还有一种可以包含多条语句,这时候就不能省略{ ... }和return
    1. find() 方法返回数组中满足提供的测试函数的第一个元素的值。否则返回 undefined。

      数组find的用法

    1. arguments 是一个对应于传递给函数的参数的类数组对象。

      arguments与数组都是亲兄弟

    1. 1、当分支较多时,当时用switch的效率是很高的。因为switch是随机访问的,就是确定了选择值之后直接跳转到那个特定的分支,但是if...else是遍历所以得可能值,知道找到符合条件的分支,如此看来switch的效率确实比ifelse要高的多。 2、switch…case只能处理case为常量(是不可以改变的值)的情况,对非常量的情况是无能为力的。例如 if (a > 1 && a < 100),是无法使用switch…case来处理的。所以,switch只能是在常量选择分支时比if...else效率高,但是if...else能应用于更多的场合,if...else比较灵活。

      switch...case和if...else的区别

    1. continue和break有点类似,区别在于 continue只是终止本次循环,接着还执行下一次循环 break用于完全结束一个循环,跳出循环体执行循环后面的语句。

      js中 break 和 continue 的区别

    1. 方法 参数 返回值 slice(start, end) start(必需) -起始位置; end(可选)-结束位置,若未指定,则默认到末尾所有元素 返回 [start,end)之间的元素 substring(start, end) start(必需) -起始位置;end(可选)-结束位置,若未指定,则默认到末尾所有元素 返回 [start,end)之间的元素 substr(start, length) start(必需)-起始位置;length(可选)-所截取的元素的个数,若未指定,则默认到末尾 返回[start, start+length)之间的元素 当传的参数都为正数的时候,substring和slice没有区别。当参数为负数时,三个函数的行为不尽相同。 slice() - 将传入的负参数与字符串长度相加; substring() - 把所有的负值置为0; substr() - 将负的第一个参数与字符串长度相加,负的第二个参数置为0。

      slice()、 substring()和substr()的区别

    1. charAt() 返回指定索引位置的字符 charCodeAt() 返回指定索引位置字符的 Unicode 值 concat() 连接两个或多个字符串,返回连接后的字符串 fromCharCode() 将 Unicode 转换为字符串 indexOf() 返回字符串中检索指定字符第一次出现的位置 lastIndexOf() 返回字符串中检索指定字符最后一次出现的位置 localeCompare() 用本地特定的顺序来比较两个字符串 match() 找到一个或多个正则表达式的匹配 replace() 替换与正则表达式匹配的子串 search() 检索与正则表达式相匹配的值 slice() 提取字符串的片断,并在新的字符串中返回被提取的部分 split() 把字符串分割为子字符串数组 substr() 从起始索引号提取字符串中指定数目的字符 substring() 提取字符串中两个指定的索引号之间的字符 toLocaleLowerCase() 根据主机的语言环境把字符串转换为小写,只有几种语言(如土耳其语)具有地方特有的大小写映射 toLocaleUpperCase() 根据主机的语言环境把字符串转换为大写,只有几种语言(如土耳其语)具有地方特有的大小写映射 toLowerCase() 把字符串转换为小写 toString() 返回字符串对象值 toUpperCase() 把字符串转换为大写 trim() 移除字符串首尾空白 valueOf() 返回某个字符串对象的原始值

      常见字符串方法

    2. === 为绝对相等,即数据类型与值都必须相等。
    3. \n 换行 \r 回车 \t tab(制表符) \b 退格符 \f 换页符

      常见转义字符

    1. 事件句柄,又称事件处理函数 event handlers.指事件发生时要进行的操作。将相应的函数或语句指定给事件句柄,则在该事件发生时,浏览器便执行指定的函数或语句,从而实现网页内容与用户操作的交互。

      事件句柄的概念

    1. 事件 描述 onchange HTML 元素改变 onclick 用户点击 HTML 元素 onmouseover 用户在一个HTML元素上移动鼠标 onmouseout 用户从一个HTML元素上移开鼠标 onkeydown 用户按下键盘按键 onload 浏览器已完成页面的加载

      常见HTML事件

    2. <button onclick="this.innerHTML=Date()">现在的时间是?</button>

      this.innerHTML的用法

    3. <button onclick="getElementById('demo').innerHTML=Date()">现在的时间是?</button>

      onclick用法

    1. JavaScript 数据类型 值类型(基本类型):字符串(String)、数字(Number)、布尔(Boolean)、对空(Null)、未定义(Undefined)、Symbol。 引用数据类型:对象(Object)、数组(Array)、函数(Function)。

      javascript的常见数据类型

  6. Oct 2021
    1. const str = 'mañana mañana' const strReverse = str.split('').reverse().join('') // => "anãnam anañam" // notice how the first word has an ã rather ñ
    1. let bookmarkList = Array.from(document.querySelectorAll('.widget>.vbox')) .map(e => e.shadowRoot) .map(e => e && e.querySelector('.device-page-list')) .find(e => e); let bookmarks = Array.from(bookmarkList.querySelectorAll('.vbox')) .map(e => `[${e.querySelector('.device-page-title').innerHTML}](${e.querySelector('x-link').innerHTML})`); copy(bookmarks.join('\n'));
    1. Vue.js vs React: Comparison of Two Most Popular JS FrameworksEugeneFrontend DeveloperVueReactHomeBlogDevelopmentVue.js vs React: Comparison of Two Most Popular JS FrameworksSep 23, 202126 min readNowadays, every company aims to create a high-quality web solution within a short time frame. To put it into practice, the developers’ community chooses from many JavaScript libraries and frameworks and debates to find the best one. At Codica, we consider Vue.js and ReactJS the most rapidly developing tools for the front-end development for many reasons. While these technologies can help create the same products and applications, both of them have pros and cons. The purpose of this article is to compare Vue.js vs React.js in different aspects: from general information to technical features. Both these web development tools have mature communities, wide support and popularity, but Vue.js is a framework and React is a library. So, why do we compare oranges and apples?

      Nowadays, every company aims to create a high-quality web solution within a short time frame. To put it into practice, the developers’ community chooses from many JavaScript libraries and frameworks and debates to find the best one.

      At Codica, we consider Vue.js and ReactJS the most rapidly developing tools for the front-end development for many reasons. While these technologies can help create the same products and applications, both of them have pros and cons.

      The purpose of this article is to compare Vue.js vs React.js in different aspects: from general information to technical features. Both these web development tools have mature communities, wide support and popularity, but Vue.js is a framework and React is a library. So, why do we compare oranges and apples?

  7. Sep 2021
    1. A neural network will predict your digit in the blue square above. Your image is 784 pixels (= 28 rows by 28 columns with black=1 and white=0). Those 784 features get fed into a 3 layer neural network; Input:784 - AvgPool:196 - Dense:100 - Softmax:10.
    1. You can help make Node.js and browsers more unified. For example, Node.js has util.promisify, which is commonly used. I don’t understand why such an essential method is not also available in browsers. In turn, browsers have APIs that Node.js should have. For example, fetch, Web Streams (The Node.js stream module is awful), Web Crypto (I’ve heard rumors this one is coming), Websockets, etc.
    2. The main reason I love Node.js is that I don’t have to deal with the awfulness that is JS front-end tooling.
  8. Aug 2021
    1. Javascript required? In other words, one cannot do this on cross-site iframes (due to cross-site scripting restrictions), is that right? As @clankill3r is suggesting, this demonstrates the need for a pure CSS solution to this problem
  9. Jul 2021
    1. function omit(obj, ...props) { const result = { ...obj }; props.forEach(function(prop) { delete result[prop]; }); return result; }
  10. Jun 2021
    1. Here is an example run of the QnA model:

      This example doesn't work. The await gets an error. Since it's not inside the promise?

    1. TensorFlow.js provides theLayers API,which mirrors the Keras API as closely as possible, in-cluding the serialization format.

      Surfing TensorFlow I was orbiting this conclusion. It's good to see it it stated clearly.

    1. import { knex } from 'knex' // this is a function that you call to instantiate knex import { Knex } from 'knex' // this is a namespace, and a type of a knex object
    1. The globalThis property provides a standard way of accessing the global this value (and hence the global object itself) across environments. Unlike similar properties such as window and self, it's guaranteed to work in window and non-window contexts. In this way, you can access the global object in a consistent manner without having to know which environment the code is being run in.
  11. May 2021
    1. Building an app with all the modern best practices — code-splitting, offline support, server-rendered views with client-side hydration — is fiendishly complicated. SvelteKit does all the boring stuff for you so that you can get on with the creative part.
    2. makes your app inaccessible to users if JavaScript fails or is disabled (which happens more often than you probably think).
  12. Apr 2021
    1. All you need is an email address or phone number associated with an account and you will get a magic link or one-time password each time you want to log in. As soon as you click the link, you'll get redirected to the app and you'll already be logged in. After that, the magic link isn't valid so no one else can use it.
  13. Mar 2021
    1. The reason Final Form does this is so that pristine will be true if you start with an uninitialized form field (i.e. value === undefined), type into it (pristine is now false), and then empty the form field. In this case, pristine should return to true, but the value that the HTML DOM gives for that input is ''. If Final Form did not treat '' and undefined as the same, any field that was ever typed in would forever be dirty, no matter what the user did.
    1. One part of React that I've always championed is how it's just JavaScript. I like that in React you don't use a distinct template syntax and instead embed JavaScript, compared to Svelte's templating language
    2. I will always find React's approach easier - at least in my head - and I think more friendly to people familiar with JavaScript who are learning a library.
    1. What are the current trends in JavaScript development?

      Performance, speed, or popularity? What are the most vital characteristics that developers seek in the tech stack? There could hardly be a single reason why certain frameworks rise, while others become the thing of the past.

      What you can do is to observe the driving directions within the front-end landscape. So let’s dive into the top JavaScript trends to watch in 2021.

    1. JavaScript needs to fly from its comfy nest, and learn to survive on its own, on equal terms with other languages and run-times. It’s time to grow up, kid.
    2. If JavaScript were detached from the client and server platforms, the pressure of being a monoculture would be lifted — the next iteration of the JavaScript language or run-time would no longer have to please every developer in the world, but instead could focus on pleasing a much smaller audience of developers who love JavaScript and thrive with it, while enabling others to move to alternative languages or run-times.
    3. Despite a growing variety of languages that compile to JavaScript, the language itself remains the dominant language in both client-side and server-side eco-systems for web development. The idea of replacing JavaScript with languages that compile to JavaScript, has been explored, and for whatever reasons, it hasn’t really liberated anyone from JavaScript.
    4. We standardize on a finite subset of JS (such as asm.js) — and avoid the endless struggle through future iterations of the JavaScript language, competing super-sets and transpilers

      asm.js and RPython sound similar (restrictive subsets)

    5. agree to accept JavaScript for what it is, but start to think of it as a kind of VM for other languages
    6. JavaScript, as a language, has some fundamental shortcomings — I think the majority of us agree on that much. But everyone has a different opinion on what precisely the shortcomings are.
    7. As to opinions about the shortcomings of the language itself, or the standard run-times, it’s important to realize that every developer has a different background, different experience, different needs, temperament, values, and a slew of other cultural motivations and concerns — individual opinions will always be largely personal and, to some degree, non-technical in nature.
    1. Another important MicroJS attribute is independence. Ember, Backbone—even Bootstrap to a degree–have hard dependencies on other libraries. For example, all three rely on jQuery. A good MicroJS library stands by itself with no dependencies. There are exceptions to the rule, but in general, any dependency is another small MicrojJS library.
    1. ECMAScript is a programming language itself, specified in the document ECMA-262. In other words, ECMA-262 is the specification of the programming language ECMAScript. JavaScript is an implementation of ECMAScript which conforms to the ECMAScript specification. JavaScript implementations can also provide additional features not described in the specification.
    1. The ECMAScript standard does not include any input/output (I/O), such as networking, storage, or graphics facilities. In practice, the web browser or other runtime system provides JavaScript APIs for I/O.
    1. Opal is a Ruby to JavaScript source-to-source compiler. It comes packed with the Ruby corelib you know and love. It is both fast as a runtime and small in its footprint.
    1. we used `backticks` to jump into native Javascript to use moment.js

      In regular Ruby, `` executes in a shell, but obviously there is no shell of that sort in JS, so it makes sense that they could (and should) repurpose that syntax for something that makes sense in context of JS -- like running native JavaScript -- prefect!

    2. Hyperstack gives you full access to the entire universe of JavaScript libraries and components directly within your Ruby code.Everything you can do in JavaScript is simple to do in Ruby; this includes passing parameters between Ruby and JavaScript and even passing Ruby methods as JavaScript callbacks.There is no need to learn JavaScript, all you need to understand is how to bridge between JS and Ruby.
    3. Think JavaScript is your only option for the front-end? Think again. Hyperstack is a Ruby DSL, compiled by Opal, bundled by Webpack, powered by React.
    1. Emscripten is an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly
    2. The Unity, Godot, and Unreal game engines provide an export option to HTML5, utilizing Emscripten.
    1. crazypython 3 hours ago [–] How do I insert a comments section with Webmention? What HTML do I add? Preferably via dynamic JS so it's self-updating.

      Maybe this is the sort of thing you're looking for? https://github.com/PlaidWeb/webmention.js/

    1. function isObject(o) { return o instanceof Object && o.constructor === Object; }
    2. An array is from a logical point of view not an object - although JavaScript handles and reports them as such. In practice however, it is not helpful to see them equal, because they are not.
    3. In case you need to verify that object is instance of particular class you have to check constructor with your particular class
    4. Arrays are definitely objects. Not sure why you think objects can't have a length property nor methods like push, Object.create(Array.prototype) is a trivial counterexample of a non-array object which has these. What makes arrays special is that they are exotic objects with a custom [[DefineOwnProperty]] essential internal method, but they are still objects.
    5. arrays are not objects from a logical point of view. I'm speaking about program logic. It is sometimes necessary to check if an array is a "real" array and definitely not an "real" object. That's what Array.isArray() is for. Imagine you have a function which accepts an object or an array of objects.
    6. function isObject (item) { return (typeof item === "object" && !Array.isArray(item) && item !== null); }
  14. Feb 2021
    1. try { const value = await localforage.getItem('somekey'); // This code runs once the value has been loaded // from the offline store. console.log(value); } catch (err) { // This code runs if there were any errors. console.log(err); }

      This looks like the best approach for me. async/await

    1. Nicely explains how to make asynchronous calls to API/services. Async/Await

    2. try/catch block to be able to catch the error

      Nice!

      The final result of they try catch block it that the code that follows below is almost exactly like how I usually code synchronously. It's so much easier to read.

    3. Callback Hell

      This is so easy to fall into. I've done it a few times. Always try to avoid this.

    4. Promises

      Never forget this. It's very important.

    1. There are times where it is useful to know whether a value was passed to run or the result of a filter default. In particular, it is useful when nil is an acceptable value.

      Yes! An illustration in ruby:

      main > h = {key_with_nil_value: nil}
      => {:key_with_nil_value=>nil}
      
      main > h[:key_with_nil_value]
      => nil
      
      main > h[:missing_key]  # this would be undefined in JavaScript (a useful distinction) rather than null, but in Ruby it's indistinguishable from the case where a nil value was actually explicitly _supplied_ by the caller/user
      => nil
      
      # so we have to check for "missingness" ("undefinedness"?) differently in Ruby
      
      main > h.key?(:key_with_nil_value)
      => true
      
      main > h.key?(:missing_key)
      => false
      

      This is one unfortunate side effect of Ruby having only nil and no built-in way to distinguish between null and undefined like in JavaScript.

  15. Jan 2021
    1. While custom iterators are a useful tool, their creation requires careful programming due to the need to explicitly maintain their internal state. Generator functions provide a powerful alternative: they allow you to define an iterative algorithm by writing a single function whose execution is not continuous. Generator functions are written using the function* syntax.
    1. { item1: "hello", item2: "world" }

      Valida in automatico l'oggetto passato con l'interfaccia?

      Non necessità di un'istanza o di specificare l'interfaccia dell'istanza?

      Interessante..

  16. Dec 2020
    1. delete is a reserved word in JavaScript. To handle DELETE requests, export a function called del instead.
    2. Note that preload will run both on the server side and on the client side. It may therefore not reference any APIs only present in the browser.
    1. Sucrase is an alternative to Babel that allows super-fast development builds. Instead of compiling a large range of JS features to be able to work in Internet Explorer, Sucrase assumes that you're developing with a recent browser or recent Node.js version, so it focuses on compiling non-standard language extensions: JSX, TypeScript, and Flow.
    2. Super-fast alternative to Babel for when you can target modern JS runtimes
    1. My frustration is mainly from Svelte's choices that are very un-JavaScript-like. It doesn't have to be "like React/Vue". React is React because it doesn't restrict what you can do with JavaScript for the most part. It's just common FP practice to fold/map.
    1. // The `.then(v => [null, v], err => [err, null])` pattern // lets you use array destructuring to get both the error and // the result
  17. Nov 2020
    1. Universal = code that can run in any JS runtime (browser and/or node). Isomorphic = application that runs the same universal code in multiple runtimes to avoid code duplication.
    2. Remember that "JavaScript" does not mean that the DOM API, AJAX, HTML5 <canvas> (and so on) are available - it just means the JavaScript scripting language is being used - that's it.
    1. Microbundle also outputs a modern bundle specially designed to work in all modern browsers. This bundle preserves most modern JS features when compiling your code, but ensures the result runs in 90% of web browsers without needing to be transpiled. Specifically, it uses preset-modules to target the set of browsers that support <script type="module"> - that allows syntax like async/await, tagged templates, arrow functions, destructured and rest parameters, etc. The result is generally smaller and faster to execute than the esm bundle
    1. Loaders use a mapping configuration to map module names to files at run-time, see RequireJs documentation and SystemJS documentation.
    1. I refactored quite a bit of tarball-fetcher now to use actual Promises and asyncawait instead of passing resolve / reject callbacks around. This makes the code quite a bit easier to follow in my opinion, but let me know if anything should be changed there.
    1. It's really helpful that Svelte stores are easy to use in plain JS. We can change a state store over completely to Svelte and make the Angular components subscribe to that store as well without needing to maintain and sync 2 copies of the state.
    1. Dart Web enables running Dart code on web platforms powered by JavaScript. With Dart Web, you compile Dart code to JavaScript code, which in turn runs in a browser
    1. Dart Sass is the primary implementation of Sass, which means it gets new features before any other implementation. It’s fast, easy to install, and it compiles to pure JavaScript which makes it easy to integrate into modern web development workflows.
    1. The rule is written @forward "<url>". It loads the module at the given URL just like @use, but it makes the public members of the loaded module available to users of your module as though they were defined directly in your module. Those members aren’t available in your module, though—if you want that, you’ll need to write a @use rule as well.

      Just like how you have to also import (@use) a JS module if you want to use it locally, even if you export (@forward) it.

    1. Mostly it is pure JS once it gets inside the browser, so you can debug effectively which is not the case with Vue for example.
    1. <input {...omitBy({pattern: undefined}, isUndefined)}>
    2. For now, using spread attributes allows you to control which attributes appear on an element. <div {...foo}> where foo is an object of attribute keys and values will add/remove attributes according to which are present and non-null.
  18. Oct 2020
    1. for (var member in myObject) delete myObject[member]; ...would seem to be pretty effective in cleaning the object in one line of code

      But checking hasOwnProperty is probably better/safer idea:

      for (var prop in obj) { if (obj.hasOwnProperty(prop)) { delete obj[prop]; } }
      
    1. Another example:

      const expensiveOperation = async (value) => {
        // return Promise.resolve(value)
          // console.log('value:', value)
          await sleep(1000)
          console.log('expensiveOperation: value:', value, 'finished')
          return value
      }
      
      var expensiveOperationDebounce = debounce(expensiveOperation, 100);
      
      // for (let num of [1, 2]) {
      //   expensiveOperationDebounce(num).then(value => {
      //     console.log(value)
      //   })
      // }
      (async () => { await sleep(0   ); console.log(await expensiveOperationDebounce(1)) })();
      (async () => { await sleep(200 ); console.log(await expensiveOperationDebounce(2)) })();
      (async () => { await sleep(1300); console.log(await expensiveOperationDebounce(3)) })();
      // setTimeout(async () => {
      //   console.log(await expensiveOperationDebounce(3))
      // }, 1300)
      

      Outputs: 1, 2, 3

      Why, if I change it to:

      (async () => { await sleep(0   ); console.log(await expensiveOperationDebounce(1)) })();
      (async () => { await sleep(200 ); console.log(await expensiveOperationDebounce(2)) })();
      (async () => { await sleep(1100); console.log(await expensiveOperationDebounce(3)) })();
      

      Does it only output 2, 3?