How to write X in both Python 3 and JavaScript
11–20 of 84 posts
Re: How to write X in both Python 3 and JavaScript
#12Re: How to write X in both Python 3 and JavaScript
#13I know all the syntax in them but I'll be damned if I can ever remember which language uses which until I've settled back in to things.
Re: How to write X in both Python 3 and JavaScript
#14Creator here! Let me know if you have any suggestions.
Re: How to write X in both Python 3 and JavaScript
#15Creator here! Let me know if you have any suggestions.
Perhabs just personal preference but I'd use
for(let element of someList){
console.log(element);
}
instead of someList.forEach(element => {
console.log(element)
})
for...of is easier to read and recognize as a loop construct at first glance, and as far as I recall it's also faster nowadays since the body of the loop is inline, whereas forEach requires the runtime to deal with a function object.Re: How to write X in both Python 3 and JavaScript
#16Re: How to write X in both Python 3 and JavaScript
#17Creator here! Let me know if you have any suggestions.
Nice list. Perhabs just personal preference but I'd use for(let element of someList){ console.log(element); } instead of someList.forEach(element => { console.log(element) }) for...of is easier to read and recognize as a loop construct at first glance, and as far as I recall it's also faster nowadays since the body of the loop is inline, whereas forEach requires the runtime to deal with a function object.
Re: How to write X in both Python 3 and JavaScript
#18A weird reference imo. Perhaps useful to build as a learning experience but I wouldn't expect who needs if/else included in a cheat sheet to be ready to learn to languages.
Re: How to write X in both Python 3 and JavaScript
#19Excellent educational tool - will be passing this around to colleagues who need it. Thanks!
Re: How to write X in both Python 3 and JavaScript
#20http://hyperpolyglot.org/ is a great website with a similar idea.