I was working with TypeScript today and I ran into a JavaScript problem that caused me some issues.
I needed to fix the number of decimal places in a temperature calculation example.
This is my original TypeScript code.
let printOutput = (fahrenheit: number, celsius: number) => { console.log(`${fahrenheit} f = ${celsius} c.`); }; let convert = (fahrenheit: number) => { let celsius = ((fahrenheit - 32) * (5 / 9)); return celsius; }; let fahrenheit = 100; let celsius = convert(fahrenheit); printOutput(fahrenheit, celsius); Returns.
I was struggling to get some code working in JavaScript and realised that I’d made a small variable type error. This is one of the problems in working with a loosely typed language like JavaScript.
When I work in C# it is strongly typed meaning that I have to declare a variable and its type at the same time. This saves a multitude of errors in my code. Unfortunately I don’t have this luxury with JavaScript and I have to be more careful with my variables.
I have recently completed the Udemy Modern JavaScript Bootcamp 2019 course run by Andrew Mead. It has been one of the most professional courses I have taken in video training. The quality and depth of training would be enough to give a learner a solid understanding of javascript. There is enough content to keep a user going for a couple of months.
I did all of the training exercises and have built up a wealth of knowledge and some best practices in JavaScript.
In the last couple of days I have been watching videos on how to use Babel in my workflow.
I have conflicting feelings on why I need to bother with Babel but am prepared to use it. The reason projects like Babel and Webpack came about is because web browsers are not keeping up with JavaScript development. There have been a number of updates to JavaScript and each browser seems to implement the new features in different timeframes.