Data Types in JS vs CS and the point of having all different types

Hey guys!
So we have different data types in Javascript. When Baue Carnes teaches JS for beginners or the Basic Js in FCC curricula he says that:
" in Computer Science data is anything that is meaningful to the computer!"
So my question is what is the theory or point of so many data types in javascript, CS or any programming languages?
Can you explain or link to a teohry video?

The computer doesn’t “know” what a number, or a string of text, or something that is true or false, or a list of values is, it needs to be told. If you didn’t have a way to tell it, how would it be able to do anything?

1 Like

how do we do that? does it depend on languages ? is there a specific data type that computers understand?

I think you’re maybe misunderstanding a bit. Programming languages are an abstraction so that a person can give a computer instructions. Machine code, which is basically the lowest level of language, and is the actual instructions that the CPU runs, is just binary numbers, one after the other (so there’s your “data type” that CPUs understand – a processor takes instructions in binary and processes them). It’s basically unreadable by a human. So you have programming languages, which let you write programs in a human-readable language, which then gets converted to machine code which the computer understands. And it’s easier to write program logic using things like "hello", or [1,2,3], or true and false, or 43.7 than it is to write millions of lines like 000000 00001 00010 00110 00000 100000

1 Like

I actually know what binary code is, what’s a programming language is and how compilers, interpreters translate human readable code to machine code.
But I am new to CS that’s why asked.
Trying to understand this:
https://www.cs.utah.edu/~germain/PPS/Topics/data_types.html

I’m not quite sure what you’re asking then – you seem to have answered your own question. Data types exist so that you can specify what type of data you’re programming with, so that in turn the compiler can convert it to the correct machine instructions. The article you linked is talking about data types used in the C programming language, when he says “the computer only knows about” he’s kinda really saying “the C compiler only knows about”

That’s what ı am trying to understand he says ‘computers’ you say c language
My question is the idea of data type in programming languages and CS.
I said ’ I know’ what binary code is but I meant the intro just taking cs101.
ı actually have no idea how computer work, what computer handles binary code? how it sees the data types. It’s probably advanced topic for me. or the wrong question

When it comes to data, all a computer can understand is 1 and 0. But sometimes we, the programers, want to store different things. Storing a Boolean is easy. It’s either a 1 or a 0.

But integers or strings or decimal numbers are more complicated to store. Data types are how we, the programers, communicate via our code with the computer about how we want to store and read our data. In JavaScript the details are handled automatically for you, but in more low level languages like C you need to declare your variables and their type.

1 Like