function isClass(fn) {
return !Object.getOwnPropertyDescriptor(fn, 'prototype').writable;
}
it relies on the fact that the prototype object of ES6 classes always non-writable.How Does React Tell a Class from a Function?
21–30 of 142 posts
Re: How Does React Tell a Class from a Function?
#22I have written maybe 200 lines of JavaScript in my life, and this article has strongly reinforced my desire to never have to write a single one more. The next time someone asks me what the problem with JavaScript is, I will send them this article. "Scheme for the browser" what a joke. Some excerpts for those that didn't have the strength to sit through the entire thing without pulling their hair out: > If you called…
One of the points of the post was that you almost definitely don't need to worry about this yourself, especially if you're using React.
Re: How Does React Tell a Class from a Function?
#23Re: How Does React Tell a Class from a Function?
#24Earlier quoted context omitted.
One of the points of the post was that you almost definitely don't need to worry about this yourself, especially if you're using React.
If you're going to be using any language seriously, you better understand how functions and objects and classes in that language work.
Re: How Does React Tell a Class from a Function?
#25Earlier quoted context omitted.
One of the points of the post was that you almost definitely don't need to worry about this yourself, especially if you're using React.
If you're going to be using any language seriously, you better understand how functions and objects and classes in that language work.
Re: How Does React Tell a Class from a Function?
#26I have written maybe 200 lines of JavaScript in my life, and this article has strongly reinforced my desire to never have to write a single one more. The next time someone asks me what the problem with JavaScript is, I will send them this article. "Scheme for the browser" what a joke. Some excerpts for those that didn't have the strength to sit through the entire thing without pulling their hair out: > If you called…
Tools without flaws are not the tools that get used for real work. Sometimes you have to suck it up and learn the quirks in the tools you have.
That's not to discourage work on improving the current situation, just an observation on practicality.
Re: How Does React Tell a Class from a Function?
#27i've used this in the past: function isClass(fn) { return !Object.getOwnPropertyDescriptor(fn, 'prototype').writable; } it relies on the fact that the prototype object of ES6 classes always non-writable.
Re: How Does React Tell a Class from a Function?
#28i've used this in the past: function isClass(fn) { return !Object.getOwnPropertyDescriptor(fn, 'prototype').writable; } it relies on the fact that the prototype object of ES6 classes always non-writable.
https://babeljs.io/repl/build/master/#?babili=false&browsers...
https://www.typescriptlang.org/play/index.html#src=function%...
Re: How Does React Tell a Class from a Function?
#29I have written maybe 200 lines of JavaScript in my life, and this article has strongly reinforced my desire to never have to write a single one more. The next time someone asks me what the problem with JavaScript is, I will send them this article. "Scheme for the browser" what a joke. Some excerpts for those that didn't have the strength to sit through the entire thing without pulling their hair out: > If you called…
You don't write js because you like, is because is a competitive advantage: - Write in one language only for both client and server side. Why is good? You just need js devs, no need to duplicate validation and other logic. I'm making a game right now and has js on the backend. I want to make the game single player, now I can just import a file from the client side and > now is single player. If your backend is in jav…
If you can't write your backend in something else and use the same devs, you have bad devs. It's not that hard to pick up a language if you understand the concepts needed to write a client and a server.
Re: How Does React Tell a Class from a Function?
#30Earlier quoted context omitted.
One of the points of the post was that you almost definitely don't need to worry about this yourself, especially if you're using React.
If you're going to be using any language seriously, you better understand how functions and objects and classes in that language work.