@drecdroid
Developer
Nothing here yet.
Nothing here yet.
No blogs yet.
Every object in javascript have a toString() method that is called when a string is required in different contexts. And every of these objects implement this method in different ways so you will receive different string for different objects. You could even override this method. If you want to print/show the structure of an object you could transform it to a JSON string. alert ( JSON .stringify ( b ))
const foo = _try => to => _do => _this => _with => regular => functions => _try + to + _do + _this + _with + regular + functions const foo = function ( _try ) { return function ( to ) { return function ( _do ) { return function ( _this ) { return function ( _with ) { return function ( regular ) { return function ( functions ) { return _try + to + _do + _this + _with + regular + functions } } } } } } } Yes, conciseness is the key here. And this really helps with composition. Some people like boilerplate, I don't. Is funny because you have as copy on your profile: The less code you use, the less there is to break
Great article!. I have to point that it wasn't required the creation of the promise at first, because fetch already returns a Promise. You could go even further: const fetch_retry = (url, options, n) => fetch(url, options). catch (error => n=== 1 ? Promise.reject(error) : fetch_retry(url, options, n -1 ));
This is a combination of how Array.prototype.filter is implemented and how javascript function declaration works. Every function declaration has a local this reference that varies depending on how the function has been called. Take the this as the context of the function. So, because Array.prototype.filter is unbound to a specific context, you can call it with a specific one, in this case it will be the sentence. According to the spec , Array.prototype.filter function is implemented something like this: Array .prototype.filter = function ( callbackFn, thisArg ) { var A = new Array (); var length = this .length; for ( var i= 0 ; i<length; i++){ var el = this [i]; if (callbackFn.call(thisArg, el, i, this )){ A.push(el); } } return A; } So it is only needed that the context has a length property and 0 to length - 1 properties, String has all of this so when calling Array.prototype.filter.call(string) the context of the function will be the string and it will loop over it. Of course you can do(although not recommended): String .prototype.filter = function ( callback, thisArg ) { return Array .prototype.filter.call( this , callback, thisArg) } So then you can just call: sentence .filter ( checkValue )
ES6 is not just about the new features, the older ones are also prevalent. So why not teach the nuances of this and prototype if they are also part of the language. Even in next versions, prototype, this, var and others will continue to exist and they are not more ES5 than ES6 or ES7, they are all part of the same language.