Reserved words in javascript

let int: number = 1;
let float: number = 1.1;

I’m confused about the above two lines of code which are used in one of the number examples. Aren’t int and float reserved words that can’t be used for variable names?

Course: Learn TypeScript: The Complete Course for Beginners - Learn Interactively
Lesson: What is a Number in TypeScript? - Learn TypeScript: The Complete Course for Beginners

Hi @Yunfei_Xie !!
yes, You’re correct that “int” and “float” are reserved words in many programming languages, including languages like Java and C#. However, in JavaScript, which is the language commonly used in web development, “int” and “float” are not reserved words. This means you can use them as variable names if you want to.

JavaScript has a single number type called “Number” which encompasses both integer and floating-point values. Unlike some other languages, JavaScript does not have explicit data types for integers and floating-point numbers.

In the code snippet you provided, “int” and “float” are simply variable names chosen by the programmer. They could have used any other valid variable name instead. The values assigned to these variables, 1 and 1.1, are examples of numerical values in JavaScript.
I hope it helps. Happy Learning :blush: