- Jan 2022
-
javascript.info javascript.info
-
new Promise(function(resolve, reject) { setTimeout(() => { throw new Error("Whoops!"); }, 1000); }).catch(alert);
-
-
blog.atomist.com blog.atomist.com
-
My gut told me calling an async function from the setTimeout callback was a bad thing. Since the setTimeout machinery ignores the return value of the function, there is no way it was awaiting on it. This means that there will be an unhandled promise. An unhandled promise could mean problems if the function called in the callback takes a long time to complete or throws an error.
-
The callback executed by setTimeout is not expected to return anything, it just ignores the returned value. Since once you enter the promise/async world in JavaScript you cannot escape, I was left to wonder what happens when the setTimeout callback returns a promise?
-
-
stackoverflow.com stackoverflow.com
-
test2 being marked async does wrap your return value in a new promise:
-
const rejectedP = Promise.reject('-'); const finallyP = rejectedP.finally(); const result1 = rejectedP; const result2 = new Promise(resolve => { const rejectedP = Promise.reject('-'); const finallyP = rejectedP.finally(); resolve(rejectedP); }); we can see that the first snippet creates two promises (result1 and rejectedP being the same) while the second snippet creates three promises. All of these promises are rejected, but the rejectedP rejection is handled by the callbacks attached to it, both through ….finally() and resolve(…) (which internally does ….then(resolve, reject)). finallyP is the promise whose rejection is not handled in the both examples. In the second example, result2 is a promise distinct from rejectedP that is also not handled, causing the second event.
-
-
stackoverflow.com stackoverflow.com
-
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); });
-
-
-
Just "ignoring" a Promise result if it is not longer needed is an antipattern in my opinion.
-
-
github.com github.com
-
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.
-
Node is entirely at liberty to limit the design the same way we crash the process on errors (which browsers do not).
-
-
www.npmjs.com www.npmjs.comco2
-
co(function* () { var result = yield Promise.resolve(true); return result;}).then(function (value) { console.log(value);}, function (err) { console.error(err.stack);});
-
Generator based control flow goodness for nodejs and the browser, using promises, letting you write non-blocking code in a nice-ish way.
-
-
thecodebarbarian.com thecodebarbarian.com
-
The power of await is that it lets you write asynchronous code using synchronous language constructs.
-
-
news.ycombinator.com news.ycombinator.com
-
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.
-
-
blog.jim-nielsen.com blog.jim-nielsen.com
-
developer.mozilla.org developer.mozilla.org
-
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
-
-
developer.mozilla.org developer.mozilla.org
-
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
-
-
stackoverflow.com stackoverflow.com
-
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
-
-
developer.mozilla.org developer.mozilla.orgimport1
-
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
-
-
medium.com medium.com
-
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
-
-
stackoverflow.blog stackoverflow.blog
-
Good lessons learned
-
-
stackoverflow.com stackoverflow.com
-
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
-
-
stackoverflow.com stackoverflow.com
-
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
-
- Dec 2021
-
niche-canada.org niche-canada.org
-
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."
-
-
niche-canada.org niche-canada.org
-
When fixing problem code, only change one thing at a time.
- Javascript == "error prone"
-
-
blog.jonudell.net blog.jonudell.net
-
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
-
-
example.com example.com
-
Programming tools
Does exists an Javascript wrapper for hypothes.is?
-
-
stackoverflow.com stackoverflow.com
-
lints para JS
-
-
stackoverflow.com stackoverflow.com
-
function intersperse<T>(this: T[], mkT: (ix: number) => T): T[] { return this.reduce((acc: T[], d, ix) => [...acc, mkT(ix), d], []).slice(1); }
-
-
svelte.dev svelte.dev
-
A Map of root-level context key-value pairs to supply to the component
-
-
a11yweekly.com a11yweekly.com
-
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.
Tags
Annotators
URL
-
- Nov 2021
-
stackoverflow.com stackoverflow.com
-
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()
-
-
developer.mozilla.org developer.mozilla.org
-
arr.sort([compareFunction]) 参数 compareFunction 可选 用来指定按某种顺序进行排列的函数。如果省略,元素按照转换为的字符串的各个字符的Unicode位点进行排序。
可以用箭头函数 arr.sort((a,b)=>a-b)
-
-
www.w3school.com.cn www.w3school.com.cn
-
默认情况下,sort() 方法将按字母和升序将值作为字符串进行排序。
-
sort() 方法对数组的项目进行排序。
Tags
Annotators
URL
-
-
yoursite.com yoursite.com
-
比如你有一个有值的数组,你想去 map 遍历每一项,这时使用箭头函数非常理想: JavaScript 代码: 12const words = ['hello', 'WORLD', 'Whatever'];const downcasedWords = words.map((word) => word.toLowerCase());
-
如果您尝试使用内联单行表达式语法,但您返回的值是对象字面量。您可能会认为这看起来应该是这样的: 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 };};
箭头函数返回值为对象时的处理方法
-
-
juejin.cn juejin.cn
-
箭头函数不会创建自己的this,它只会从自己的作用域链的上一层继承this。
Tags
Annotators
URL
-
-
www.liaoxuefeng.com www.liaoxuefeng.com箭头函数3
-
如果要返回一个对象,就要注意,如果是单表达式,这么写的话会报错: // SyntaxError: x => { foo: x } 因为和函数体的{ ... }有语法冲突,所以要改为: // ok: x => ({ foo: x })
-
参数不是一个,就需要用括号()括起来
-
箭头函数有两种格式,一种像上面的,只包含一个表达式,连{ ... }和return都省略掉了。还有一种可以包含多条语句,这时候就不能省略{ ... }和return
-
-
developer.mozilla.org developer.mozilla.org
-
find() 方法返回数组中满足提供的测试函数的第一个元素的值。否则返回 undefined。
数组find的用法
-
-
developer.mozilla.org developer.mozilla.org
-
arguments 是一个对应于传递给函数的参数的类数组对象。
arguments与数组都是亲兄弟
-
-
juejin.cn juejin.cn
-
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的区别
Tags
Annotators
URL
-
-
blog.csdn.net blog.csdn.net
-
continue和break有点类似,区别在于 continue只是终止本次循环,接着还执行下一次循环 break用于完全结束一个循环,跳出循环体执行循环后面的语句。
js中 break 和 continue 的区别
-
-
www.jianshu.com www.jianshu.com
-
方法 参数 返回值 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()的区别
-
-
www.runoob.com www.runoob.com
-
charAt() 返回指定索引位置的字符 charCodeAt() 返回指定索引位置字符的 Unicode 值 concat() 连接两个或多个字符串,返回连接后的字符串 fromCharCode() 将 Unicode 转换为字符串 indexOf() 返回字符串中检索指定字符第一次出现的位置 lastIndexOf() 返回字符串中检索指定字符最后一次出现的位置 localeCompare() 用本地特定的顺序来比较两个字符串 match() 找到一个或多个正则表达式的匹配 replace() 替换与正则表达式匹配的子串 search() 检索与正则表达式相匹配的值 slice() 提取字符串的片断,并在新的字符串中返回被提取的部分 split() 把字符串分割为子字符串数组 substr() 从起始索引号提取字符串中指定数目的字符 substring() 提取字符串中两个指定的索引号之间的字符 toLocaleLowerCase() 根据主机的语言环境把字符串转换为小写,只有几种语言(如土耳其语)具有地方特有的大小写映射 toLocaleUpperCase() 根据主机的语言环境把字符串转换为大写,只有几种语言(如土耳其语)具有地方特有的大小写映射 toLowerCase() 把字符串转换为小写 toString() 返回字符串对象值 toUpperCase() 把字符串转换为大写 trim() 移除字符串首尾空白 valueOf() 返回某个字符串对象的原始值
常见字符串方法
-
=== 为绝对相等,即数据类型与值都必须相等。
-
\n 换行 \r 回车 \t tab(制表符) \b 退格符 \f 换页符
常见转义字符
-
-
zhuanlan.zhihu.com zhuanlan.zhihu.com
-
事件句柄,又称事件处理函数 event handlers.指事件发生时要进行的操作。将相应的函数或语句指定给事件句柄,则在该事件发生时,浏览器便执行指定的函数或语句,从而实现网页内容与用户操作的交互。
事件句柄的概念
-
-
www.runoob.com www.runoob.com
-
事件 描述 onchange HTML 元素改变 onclick 用户点击 HTML 元素 onmouseover 用户在一个HTML元素上移动鼠标 onmouseout 用户从一个HTML元素上移开鼠标 onkeydown 用户按下键盘按键 onload 浏览器已完成页面的加载
常见HTML事件
-
<button onclick="this.innerHTML=Date()">现在的时间是?</button>
this.innerHTML的用法
-
<button onclick="getElementById('demo').innerHTML=Date()">现在的时间是?</button>
onclick用法
-
-
www.runoob.com www.runoob.com
-
JavaScript 数据类型 值类型(基本类型):字符串(String)、数字(Number)、布尔(Boolean)、对空(Null)、未定义(Undefined)、Symbol。 引用数据类型:对象(Object)、数组(Array)、函数(Function)。
javascript的常见数据类型
Tags
Annotators
URL
-
-
www.mobindustry.net www.mobindustry.net
-
7 Most Popular JavaScript Libraries in 2021
-
-
www.simoahava.com www.simoahava.com
-
Article explaning all the reasons behind the structure of the GTM snippet
-
-
-
Even if it's const, an object can still have properties added later returning any arbitrary type. Indexing into the object would then have to return any - and that's an implicit any.
-
fresh (i.e. provably do not have properties we don't know about)
-
-
-
Check whether a value is defined (non-nullable), meaning it is neither `null` or `undefined`. This can be useful as a type guard, as for example, `[1, null].filter(Boolean)` does not always type-guard correctly.
-
- Oct 2021
-
benpickles.github.io benpickles.github.io
-
developer.mozilla.org developer.mozilla.org
-
const str = 'mañana mañana' const strReverse = str.split('').reverse().join('') // => "anãnam anañam" // notice how the first word has an ã rather ñ
-
-
developer.mozilla.org developer.mozilla.org
-
A model for understanding equality comparisons
-
-
-
For those coming from Ruby, Javascript has no builtin method like Ruby’s Array#compact.
-
-
android.stackexchange.com android.stackexchange.com
-
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'));
-
-
-
Lean Canvas in JavaScript
See my Coding Challenges.
-
-
-
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?
-
-
blog.stackfindover.com blog.stackfindover.com
-
How to build Currency Converter in JavaScript
-
- Sep 2021
-
stackoverflow.com stackoverflow.com
-
Array.from(Array(10).keys()) //=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-
-
www.ccom.ucsd.edu www.ccom.ucsd.edu
-
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.
Tags
Annotators
URL
-
-
testing-library.com testing-library.com
-
though we recommend Jest as our preference, the library works with any framework
-
-
github.com github.com
-
the bug is actually in webpack, related to fs in the web target.
-
-
blog.sindresorhus.com blog.sindresorhus.com
-
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.
-
The main reason I love Node.js is that I don’t have to deal with the awfulness that is JS front-end tooling.
-
-
-
Webpacker used to configure Webpack indirectly, which lead to a complicated secondary configuration process. This was done in order to provide default configurations for the most popular frameworks, but ended up creating more complexity than it cured. So now Webpacker delegates all configuration directly to Webpack's default configuration setup.
more trouble than it's worth
- creating more complexity than it cured
Tags
- complicated
- removing feature that is more trouble than it's worth (not worth the effort to continue to maintain / fix bugs caused by keeping it)
- too complicated
- changed their mind/opinion
- Why can't this be easier/simpler? Why does it have to be so hard/complicated?
- newer/better ways of doing things
- doing more harm than good
- too hard/complicated/non-trivial
- modern javascript development is complicated
- more trouble than it's worth
Annotators
URL
-
- Aug 2021
-
stackoverflow.com stackoverflow.com
-
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
-
-
-
Please read https://stackoverflow.com/questions/41750390/what-does-all-legal-javascript-is-legal-typescript-mean
-
-
developer.mozilla.org developer.mozilla.org
-
However instead of using array.length for latter items; e.g. array[array.length-1] for the last item, you can call array.at(-1)
-
- Jul 2021
-
-
function omit(obj, ...props) { const result = { ...obj }; props.forEach(function(prop) { delete result[prop]; }); return result; }
-
-
www.amitmerchant.com www.amitmerchant.com
-
You can use computed properties along with the omit keyword in this case like so. const varName = 'name'; const { [varName]:omit, ...updatedUser } = user;
first sighting: omit keyword
Or should that be "omitted"? https://hyp.is/lmYWKvAcEeurHLvjfrKYrw/stackoverflow.com/questions/43011742/how-to-omit-specific-properties-from-an-object-in-javascript
-
-
stackoverflow.com stackoverflow.com
-
function omit(key, obj) { const { [key]: omitted, ...rest } = obj; return rest; }
omitted
-
"modern environments" meaning if you're shipping un-transpiled code, this will work on 93% of browsers. See full compatibility at caniuse.com/…
-
- Jun 2021
-
github.com github.com
-
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?
-
-
stackoverflow.com stackoverflow.com
-
cloud.google.com cloud.google.com
-
"dividing n-dimensional space with a hyperplane."
-
-
-
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.
Tags
Annotators
URL
-
-
-
Emit clean, idiomatic, recognizable JavaScript code.
-
-
developer.mozilla.org developer.mozilla.org
-
The encapsulation is enforced by the language. It is a syntax error to refer to # names from out of scope.
-
-
stackoverflow.com stackoverflow.com
-
in languages (like JavaScript and Java) where external objects do have direct access to instance vars
-
-
stackoverflow.com stackoverflow.com
-
Note: there’s no way to define private methods, getters and setters. but a proposal is there https://github.com/tc39/proposal-private-methods
-
-
babeljs.io babeljs.io
-
Private instance accessors (getters and setters)
-
class Person { #firstname = "Babel"; #lastname = "JS"; get #name() { return this.#firstname + " " + this.#lastname; } sayHi() { alert(`Hi, ${this.#name}!`); } }
-
-
basarat.gitbook.io basarat.gitbook.ioClasses1
-
If an access modifier is not specified it is implicitly public as that matches the convenient nature of JavaScript 🌹.
-
-
-
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
-
-
developer.mozilla.org developer.mozilla.orgProxy2
-
get: function(target, prop, receiver) { return "world"; }
-
With the help of the Reflect class we can give some accessors the original behavior and redefine others:
-
-
developer.mozilla.org developer.mozilla.org
-
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.
-
-
github.com github.com
-
Unlike browsers, you can access raw Set-Cookie headers manually using Headers.raw(). This is a node-fetch only API.
-
- May 2021
-
-
We implemented isomorphic fetching (i.e. fetching with the browser's implementation on the client and node-fetch on the server)
-
-
kit.svelte.dev kit.svelte.dev
-
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.
-
makes your app inaccessible to users if JavaScript fails or is disabled (which happens more often than you probably think).
-
- Apr 2021
-
www.michaelbransonsmith.net www.michaelbransonsmith.net
-
-
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.
-
- Mar 2021
-
final-form.org final-form.org
-
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.
-
-
www.jackfranklin.co.uk www.jackfranklin.co.uk
-
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
-
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.
-
-
-
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.
Tags
Annotators
URL
-
-
www.freecodecamp.org www.freecodecamp.org
-
medium.com medium.com
-
www.sitepoint.com www.sitepoint.com
-
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.
-
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.
-
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.
-
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)
-
agree to accept JavaScript for what it is, but start to think of it as a kind of VM for other languages
-
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.
-
-
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.
Tags
- good point
- software preferences are personal
- everyone has different background/culture/experience
- everyone has different opinions
- reaction / reacting to
- JavaScript: flaws/shortcomings/cons
- avoid giving partiality/advantage/bias to any specific option
- standardization
- software project created to address shortcomings in another project
- non-technical reasons
- everyone has different preferences
- JavaScript: as a process VM
- programming languages
- annotation meta: may need new tag
- RPython
- culture
- disadvantages/drawbacks/cons
- asm.js
- JavaScript ecosystem
- what is important/necessary for one person may not be for another
- separation of concerns
- competition in open-source software
- good idea
- neutral/unbiased/agnostic
- neutral ground
- the high churn in JavaScript tooling
- runtime environment
- software freedom
- level playing field
- software trends
- programming languages: choosing the best language for the job
- JavaScript
- +0.9
Annotators
URL
-
-
ythakker.medium.com ythakker.medium.com
-
www.codemag.com www.codemag.com
-
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.
-
-
github.com github.comd3/d31
-
D3 now passes events directly to listeners, replacing the d3.event global and bringing D3 inline with vanilla JavaScript and most other frameworks.
-
-
en.wikipedia.org en.wikipedia.org
-
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.
-
-
en.wikipedia.org en.wikipedia.org
-
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.
-
-
opalrb.com opalrb.com
-
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.
-
-
hyperstack.org hyperstack.org
-
-
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!
-
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.
-
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.
-
-
en.wikipedia.org en.wikipedia.org
-
Emscripten is an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly
-
The Unity, Godot, and Unreal game engines provide an export option to HTML5, utilizing Emscripten.
-
-
stackoverflow.com stackoverflow.com
-
[...document.querySelectorAll("*")].filter(e => e.childNodes && [...e.childNodes].find(n => n.nodeValue?.match("❤")))
-
Super modern one-line approach with optional chaining operator
-
-
news.ycombinator.com news.ycombinator.com
-
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/
Tags
Annotators
URL
-
-
github.com github.com
-
github.com github.com
-
stackoverflow.com stackoverflow.com
-
You really don't need underscore/lodash for this ... nowadays anyways
-
-
stackoverflow.com stackoverflow.com
-
function isObject(o) { return o instanceof Object && o.constructor === Object; }
-
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.
-
In case you need to verify that object is instance of particular class you have to check constructor with your particular class
-
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.
-
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.
-
function isObject (item) { return (typeof item === "object" && !Array.isArray(item) && item !== null); }
-
-
-
github.com github.com
Tags
Annotators
URL
-
- Feb 2021
-
github.com github.com
-
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
-
-
-
Nicely explains how to make asynchronous calls to API/services. Async/Await
-
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.
-
Callback Hell
This is so easy to fall into. I've done it a few times. Always try to avoid this.
-
Promises
Never forget this. It's very important.
-
-
jrsinclair.com jrsinclair.com
-
github.com github.com
-
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 betweennull
andundefined
like in JavaScript.
-
-
-
we’re going to look how improved pattern matching and rightward assignment make it possible to “destructure” hashes and arrays in Ruby 3—much like how you’d accomplish it in, say, JavaScript
-
-
www.codewall.co.uk www.codewall.co.uk
-
Using details/summary for dropdown nav menu without requiring any JavaScript
-
-
-
What do you do with your API key? "WHERE DO I PUT IT?!?" https://youtu.be/ecT42O6I_WI?t=338
Also, suggests to get a JSON formatter browser extension. e.g.: "JSON Formatter" from the Chrome Web Store Here's a good one: https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh/
Tags
Annotators
URL
-
- Jan 2021
-
developer.mozilla.org developer.mozilla.org
-
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.
-
-
atomiks.github.io atomiks.github.io
-
www.npmjs.com www.npmjs.com
-
-
Think first: why do you want to use it in the browser? Remember, servers must never trust browsers. You can't sanitize HTML for saving on the server anywhere else but on the server.
-
-
www.npmjs.com www.npmjs.com
-
learnxinyminutes.com learnxinyminutes.com
-
{ 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..
-
- Dec 2020
-
sapper.svelte.dev sapper.svelte.dev
-
delete is a reserved word in JavaScript. To handle DELETE requests, export a function called del instead.
-
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.
-
-
github.com github.com
-
-
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.
-
Super-fast alternative to Babel for when you can target modern JS runtimes
-
-
github.com github.com
-
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.
-
-
ifovea.net ifovea.net
Tags
Annotators
URL
-
-
ifovea.net ifovea.net
-
ifovea.net ifovea.net
-
ifovea.net ifovea.net
-
ifovea.net ifovea.net
-
ifovea.net ifovea.net
-
ifovea.net ifovea.net
-
thecodebarbarian.com thecodebarbarian.com
-
// The `.then(v => [null, v], err => [err, null])` pattern // lets you use array destructuring to get both the error and // the result
-
- Nov 2020
-
www.cleveroad.com www.cleveroad.com
-
How to Hire JavaScript Developers in 2019: A Full Guide
Read this article to learn how to hire JavaScript developers.
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
this in NodeJS global scope is the current module.exports object, not the global object
-
If you want a reference to the global object that works in any context, you can read this from a directly-called function. const global = (function() {return this})();. This evaluates to window in the browser, self in a service worker and global in nodejs.
-
emphasizing that 'this' and 'global object' are two different things not only in Node.js but in JavaScript in general
-
-
stackoverflow.com stackoverflow.com
-
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.
-
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.
-
-
css-tricks.com css-tricks.com
-
-
let root = document.documentElement; root.addEventListener("mousemove", e => { root.style.setProperty('--mouse-x', e.clientX + "px"); root.style.setProperty('--mouse-y', e.clientY + "px"); });
-
-
github.com github.com
-
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
-
-
github.com github.com
-
You can either use require to bypass typescript special import.
-
-
www.npmjs.com www.npmjs.com
-
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
-
-
www.typescriptlang.org www.typescriptlang.org
-
Loaders use a mapping configuration to map module names to files at run-time, see RequireJs documentation and SystemJS documentation.
-
-
github.com github.com
-
Supersedes (and first sighting at): https://github.com/wycats/javascript-decorators
-
-
github.com github.com
-
Evaluating this class results in installing the name function onto Person.prototype, roughly like this:
-
-
github.com github.com
-
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.
-
-
github.com github.com
-
Avoid transpilers like Babel and Bublé (and if you're using TypeScript, target a modern version of JavaScript)
-
-
imfeld.dev imfeld.dev
-
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.
-
-
-
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
Tags
Annotators
URL
-
-
-
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.
-
-
sass-lang.com sass-lang.com
-
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.
-
-
-
news.ycombinator.com news.ycombinator.com
-
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.
Tags
Annotators
URL
-
-
github.com github.com
-
<input {...omitBy({pattern: undefined}, isUndefined)}>
-
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.
-