Skip to main content

Posts

Showing posts with the label number

JavaScript Basic: Five Primitive Data Types You Must Know

JavaScript (JS) is a programming language which can add logic and interactivity to a page. If we treat HTML as a noun and treat CSS as a adjective in a sentence, we can treat JS as a verb which is the one to take action. Today, I learned five primitive datatypes about JS. Numbers Numbers are very simple, just like 4, 10, -29.etc It can do some math . For example we type a simple math in the console (open any web page on Google Chrome, right click and inspect the page, click "console" next to the "Element" bar): I type "4+26" and the result is calculated automatically. The JS follows the order of operations that all regular math follows as well. For example, (3+5)*8=8*8=64. Besides simple math, JS can also do modulo which is a reminder operator. It has "%" sign between two numbers. For example: The result shows when 10 divide 3, the reminder is 1 (3*3+1=10). Strings They can be text inside single or double quotes Fo...